Skip to content

Commit

Permalink
Warn about markdown links in .bib file
Browse files Browse the repository at this point in the history
  • Loading branch information
goerz committed Nov 5, 2023
1 parent b8064cc commit 1bba46e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [Unreleased][]

### Fixed

* Warn about markdown link syntax in `.bib` files [[#60][]]


## [Version 1.3.1][1.3.1] - 2023-11-02

### Fixed
Expand Down Expand Up @@ -142,6 +149,7 @@ There were several bugs and limitations in version `1.2.x` for which some existi
[1.1.0]: https://github.com/JuliaDocs/DocumenterCitations.jl/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/JuliaDocs/DocumenterCitations.jl/compare/v0.2.12...v1.0.0
[#61]: https://github.com/JuliaDocs/DocumenterCitations.jl/pull/61
[#60]: https://github.com/JuliaDocs/DocumenterCitations.jl/issues/60
[#59]: https://github.com/JuliaDocs/DocumenterCitations.jl/issues/59
[#56]: https://github.com/JuliaDocs/DocumenterCitations.jl/pull/56
[#53]: https://github.com/JuliaDocs/DocumenterCitations.jl/issues/53
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DocumenterCitations"
uuid = "daee34ce-89f3-4625-b898-19384cb65244"
authors = ["Michael Goerz <[email protected]>"]
version = "1.3.1+dev"
version = "1.3.2-dev"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
4 changes: 4 additions & 0 deletions src/tex_to_markdown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ end


function tex_to_markdown(tex_str; transform_case=s -> s, debug=_DEBUG)
if contains(tex_str, "](http")
# https://github.com/JuliaDocs/DocumenterCitations.jl/issues/60
@warn "The tex string $(repr(tex_str)) appears to contain a link in markdown syntax. Links in a `.bib` entry should use the `\\href` tex command."
end
try
md_str = _process_tex(tex_str; transform_case=transform_case, debug=debug)
return Unicode.normalize(md_str)
Expand Down
10 changes: 10 additions & 0 deletions test/test_tex_to_markdown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ end
@test c.value.msg ==
"Cannot evaluate \\href: ArgumentError(\"Unsupported command: \\\\error. Please report a bug.\")"

s = "The krotov Pyhon package is available on [Github](https://github.com/qucontrol/krotov)"
c = IOCapture.capture(rethrow=Union{}) do
tex_to_markdown(s)
end
@test c.value == s
@test contains(
c.output,
"Warning: The tex string \"The krotov Pyhon package is available on [Github](https://github.com/qucontrol/krotov)\" appears to contain a link in markdown syntax"
)

end


Expand Down

0 comments on commit 1bba46e

Please sign in to comment.