Kolaru / MathTeXEngine.jl

A latex math mode engine in pure Julia.
MIT License
97 stars 19 forks source link

implement `\text` and friends #70

Closed Moelf closed 2 years ago

Moelf commented 2 years ago

close #39, close #52

Moelf commented 2 years ago
julia> generate_tex_elements(L"\textit{123}")
3-element Vector{Any}:
 (TeXChar '1' [index 18 in NewComputerModern - 10 Italic], [0.0, 0.0], 1.0)
 (TeXChar '2' [index 19 in NewComputerModern - 10 Italic], [0.5109999775886536, 0.0], 1.0)
 (TeXChar '3' [index 20 in NewComputerModern - 10 Italic], [1.0219999551773071, 0.0], 1.0)

julia> generate_tex_elements(L"\text{123}")
3-element Vector{Any}:
 (TeXChar '1' [index 18 in NewComputerModern Math - Regular], [0.0, 0.0], 1.0)
 (TeXChar '2' [index 19 in NewComputerModern Math - Regular], [0.5, 0.0], 1.0)
 (TeXChar '3' [index 20 in NewComputerModern Math - Regular], [1.0, 0.0], 1.0)

not sure how to un-remove the space

Kolaru commented 2 years ago

Do you know if there is additional rules different from in \text than otherwise in math mode ? If it is only the spaces, I can special case it. Otherwise, I think I'll need to think more about the parser.

Moelf commented 2 years ago

I'm not a tex guru, but I read

I think the main thing is just space and fonts

Moelf commented 2 years ago

to me the most important aspect of this PR is to not error, because people tend to think it just can't be done.

whereas if it's just the spacing is wrong, they would immediately know to add a ~ or whatever

codecov-commenter commented 2 years ago

Codecov Report

Merging #70 (f2bed42) into master (c757b00) will increase coverage by 0.28%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #70      +/-   ##
==========================================
+ Coverage   78.45%   78.74%   +0.28%     
==========================================
  Files           7        7              
  Lines         441      447       +6     
==========================================
+ Hits          346      352       +6     
  Misses         95       95              
Impacted Files Coverage Δ
src/parser/commands_registration.jl 34.78% <ø> (ø)
src/engine/layout.jl 89.60% <100.00%> (ø)
src/parser/parser.jl 73.68% <100.00%> (+1.08%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c757b00...f2bed42. Read the comment docs.

Kolaru commented 2 years ago

I special cased the spaces.

Thanks a lot for the contribution !