Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly format en and em dashes in reference titles #17

Merged
merged 4 commits into from
Oct 23, 2020

Conversation

ali-ramadhan
Copy link
Owner

This PR starts adding support for converting common TeX to unicode starting with en and em dashes.

This PR depends on #13.

Resolves #11 (?)

@ali-ramadhan
Copy link
Owner Author

It's a very naive approach that scales as O(B*R) where B is the number of items in the bibliography and R is the number of possible replacements.

But maybe we don't expect too many replacements. Certainly there aren't that many text replacements we want to do for titles I think.

Comment on lines +12 to +15
for replacement in tex2unicode_replacements
s = replace(s, replacement)
end
return s
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use multiple pairs in one replace

Suggested change
for replacement in tex2unicode_replacements
s = replace(s, replacement)
end
return s
replace(s, tex2unicode_replacements...)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah nice!

Copy link
Owner Author

@ali-ramadhan ali-ramadhan Oct 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah looks like

replace(A, old_new::Pair...; [count::Integer])

is defined in general but for strings we are stuck with

replace(s::AbstractString, pat=>r; [count::Integer])

😞

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I just realised. Upstream issue JuliaLang/julia#35327

Copy link
Collaborator

@charleskawczynski charleskawczynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine by me. Rebase/squash first?

@ali-ramadhan ali-ramadhan merged commit cbb177b into master Oct 23, 2020
@ali-ramadhan ali-ramadhan deleted the ar/tex-2-unicode branch October 23, 2020 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert common TeX to unicode
3 participants