Code Duplication    Length = 21-31 lines in 3 locations

doorstop/core/publishers/latex.py 1 location

@@ 211-241 (lines=31) @@
208
        else:
209
            return "\\begin{{quote}} \\verb|{r}|\\end{{quote}}".format(r=item.ref)
210
211
    def format_references(self, item):
212
        """Format an external reference in LaTeX."""
213
        if settings.CHECK_REF:
214
            references = item.find_references()
215
            text_refs = []
216
            for ref_item in references:
217
                path, line = ref_item
218
                path = path.replace("\\", "/")  # always use unix-style paths
219
220
                if line:
221
                    text_refs.append(
222
                        "\\begin{{quote}} \\verb|{p}| (line {line})\\end{{quote}}".format(
223
                            p=path, line=line
224
                        )
225
                    )
226
                else:
227
                    text_refs.append(
228
                        "\\begin{{quote}} \\verb|{p}|\\end{{quote}}".format(p=path)
229
                    )
230
231
            return "\n".join(ref for ref in text_refs)
232
        else:
233
            references = item.references
234
            text_refs = []
235
            for ref_item in references:
236
                path = ref_item["path"]
237
                path = path.replace("\\", "/")  # always use unix-style paths
238
                text_refs.append(
239
                    "\\begin{{quote}} \\verb|{r}|\\end{{quote}}".format(r=path)
240
                )
241
            return "\n".join(ref for ref in text_refs)
242
243
    def format_links(self, items, linkify, to_html=False):
244
        """Format a list of linked items in LaTeX."""

doorstop/core/publishers/markdown.py 1 location

@@ 38-60 (lines=23) @@
35
        else:
36
            return "> '{r}'".format(r=item.ref)
37
38
    def format_references(self, item):
39
        """Format an external reference in Markdown."""
40
        if settings.CHECK_REF:
41
            references = item.find_references()
42
            text_refs = []
43
            for ref_item in references:
44
                path, line = ref_item
45
                path = path.replace("\\", "/")  # always use unix-style paths
46
47
                if line:
48
                    text_refs.append("> `{p}` (line {line})".format(p=path, line=line))
49
                else:
50
                    text_refs.append("> `{p}`".format(p=path))
51
52
            return "\n".join(ref for ref in text_refs)
53
        else:
54
            references = item.references
55
            text_refs = []
56
            for ref_item in references:
57
                path = ref_item["path"]
58
                path = path.replace("\\", "/")  # always use unix-style paths
59
                text_refs.append("> '{r}'".format(r=path))
60
            return "\n".join(ref for ref in text_refs)
61
62
    def format_links(self, items, linkify, to_html=False):
63
        """Format a list of linked items in Markdown."""

doorstop/core/publishers/text.py 1 location

@@ 134-154 (lines=21) @@
131
        else:
132
            return "Reference: '{r}'".format(r=item.ref)
133
134
    def format_references(self, item):
135
        """Format an external reference in text."""
136
        if settings.CHECK_REF:
137
            ref = item.find_references()
138
            text_refs = []
139
            for ref_item in ref:
140
                path, line = ref_item
141
                path = path.replace("\\", "/")  # always use unix-style paths
142
                if line:
143
                    text_refs.append("{p} (line {line})".format(p=path, line=line))
144
                else:
145
                    text_refs.append("{p}".format(p=path))
146
            return "Reference: {}".format(", ".join(ref for ref in text_refs))
147
        else:
148
            references = item.references
149
            text_refs = []
150
            for ref_item in references:
151
                path = ref_item["path"]
152
                path = path.replace("\\", "/")  # always use unix-style paths
153
                text_refs.append("'{p}'".format(p=path))
154
            return "Reference: {}".format(", ".join(text_ref for text_ref in text_refs))
155
156
    def _chunks(self, text):
157
        """Yield wrapped lines of text."""