Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
xrotwang committed Dec 5, 2023
1 parent 30cf065 commit c7a0869
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changes

## [Unreleased]

- Fixed bug whereby non-source CLDF Markdown links were not replaced when a
link to insert a reference list of cited sources was present.


## [v1.0.1] - 2023-12-01

- Fixed bug whereby CLDF examples were not properly HTML escaped when rendered as Markdown.
Expand Down
3 changes: 2 additions & 1 deletion src/cldfviz/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def render_link(self, ml):
ctx['ctx'] = [s for s in self.get_object(ml) if s.id in self.cited]
ctx["with_anchor"] = True
return self.render_template('Source', ctx, index=True)
return ml
return ml # pragma: no cover

if ref_link: # So we need a second pass.
self.with_partial_local_reflist = True
Expand All @@ -179,6 +179,7 @@ def render(self, simple_link_detection=True, markdown_kw=None):
if MarkdownLink.from_match(ml).url.startswith('#source-'))

# 2. Insert the pruned list of sources:
self.text = md
md = super().render(
simple_link_detection=simple_link_detection, markdown_kw=markdown_kw)
return md
13 changes: 13 additions & 0 deletions tests/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,16 @@ def test_templates(Wordlist, Generic, StructureDataset, comp, query, oid, ds, ex
else:
print(res)
assert expected in res


def test_reference_list(StructureDataset):
text = """# [](ParameterTable?__template__=property.md&name=name#cldf:B)
See [](Source?ref&with_internal_ref_link#cldf:Peterson2017) and [ex](http://example.com)
[References](Source?cited_only#cldf:__all__)
"""
res = render(text, StructureDataset)
assert "Gender/Noun classes" in res
assert 'Peterson 2017' in res
assert "Fitting the pieces together" in res

0 comments on commit c7a0869

Please sign in to comment.