-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix potential bugs by switching from Formatting.jl to Format.jl
- Loading branch information
1 parent
6b869c3
commit a7ee6f5
Showing
6 changed files
with
25 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,16 +2,15 @@ name = "Latexify" | |
uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" | ||
authors = ["Niklas Korsbo <[email protected]>"] | ||
repo = "https://github.com/korsbo/Latexify.jl.git" | ||
version = "0.16.1" | ||
version = "0.16.2" | ||
|
||
[deps] | ||
Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0" | ||
Format = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8" | ||
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" | ||
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" | ||
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" | ||
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" | ||
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" | ||
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" | ||
Requires = "ae029012-a4dd-5104-9daa-d747884805df" | ||
|
||
[weakdeps] | ||
|
@@ -23,7 +22,7 @@ DataFramesExt = "DataFrames" | |
SymEngineExt = "SymEngine" | ||
|
||
[compat] | ||
Formatting = "0.4" | ||
Format = "1.3" | ||
LaTeXStrings = "0.3, 1" | ||
MacroTools = "0.4 - 0.5" | ||
OrderedCollections = "1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[deps] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0" | ||
Format = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8" | ||
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" | ||
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,48 @@ | ||
abstract type AbstractNumberFormatter end | ||
|
||
(::AbstractNumberFormatter)(x) = string(x) | ||
|
||
const float_regex = r"(?'mantissa'(?'before_dp'(?'sign'-?)(?'before_dp_nosign'\d+))(\.(?'after_dp'\d+))?)(?'e_or_E'e)(?'raw_exp'(?'sign_exp'-?)\+?0*(?'mag_exp'\d+))"i | ||
|
||
struct PlainNumberFormatter <: AbstractNumberFormatter end | ||
|
||
(::PlainNumberFormatter)(x) = string(x) | ||
|
||
|
||
struct PrintfNumberFormatter <: AbstractNumberFormatter | ||
fmt::String | ||
f::Function | ||
|
||
PrintfNumberFormatter(fmt::String) = new(fmt, Format.generate_formatter(fmt)) | ||
end | ||
PrintfNumberFormatter(fmt::String) = PrintfNumberFormatter(fmt, Formatting.generate_formatter(fmt)) | ||
(f::PrintfNumberFormatter)(x) = f.f(x) | ||
|
||
(f::PrintfNumberFormatter)(x) = f.f(x) | ||
|
||
struct StyledNumberFormatter <: AbstractNumberFormatter | ||
fmt::String | ||
f::Function | ||
|
||
StyledNumberFormatter(fmt::String="%.4g") = new(fmt) | ||
|
||
end | ||
|
||
function StyledNumberFormatter(significant_digits::Int) | ||
return StyledNumberFormatter("%.$(significant_digits)g") | ||
StyledNumberFormatter(fmt::String="%.4g") = new(fmt, Format.generate_formatter(fmt)) | ||
end | ||
|
||
(f::StyledNumberFormatter)(x) = string(x) | ||
function (f::StyledNumberFormatter)(x::AbstractFloat) | ||
s = @eval @sprintf $(f.fmt) $x | ||
return replace(s, float_regex => s"\g<mantissa> \\mathrm{\g<e_or_E>}{\g<sign_exp>\g<mag_exp>}") | ||
end | ||
StyledNumberFormatter(significant_digits::Int) = StyledNumberFormatter("%.$(significant_digits)g") | ||
|
||
(f::StyledNumberFormatter)(x::AbstractFloat) = | ||
replace(f.f(x), float_regex => s"\g<mantissa> \\mathrm{\g<e_or_E>}{\g<sign_exp>\g<mag_exp>}") | ||
(f::StyledNumberFormatter)(x::Unsigned) = "\\mathtt{0x$(string(x; base=16, pad=2sizeof(x)))}" | ||
|
||
|
||
struct FancyNumberFormatter <: AbstractNumberFormatter | ||
fmt::String | ||
f::Function | ||
exponent_format::SubstitutionString | ||
|
||
function FancyNumberFormatter(fmt::String="%.4g", | ||
exponent_format::SubstitutionString=s"\g<mantissa> \\cdot 10^{\g<sign_exp>\g<mag_exp>}") | ||
return new(fmt, exponent_format) | ||
end | ||
FancyNumberFormatter(fmt::String="%.4g", | ||
exponent_format::SubstitutionString=s"\g<mantissa> \\cdot 10^{\g<sign_exp>\g<mag_exp>}") = new(fmt, Format.generate_formatter(fmt), exponent_format) | ||
end | ||
|
||
function FancyNumberFormatter(fmt::String, mult_symbol) | ||
return FancyNumberFormatter(fmt, SubstitutionString("\\g<mantissa> $(escape_string(mult_symbol)) 10^{\\g<sign_exp>\\g<mag_exp>}")) | ||
end | ||
function FancyNumberFormatter(significant_digits, mult_symbol="\\cdot") | ||
return FancyNumberFormatter("%.$(significant_digits)g", mult_symbol) | ||
end | ||
FancyNumberFormatter(fmt::String, mult_symbol) = | ||
FancyNumberFormatter(fmt, SubstitutionString("\\g<mantissa> $(escape_string(mult_symbol)) 10^{\\g<sign_exp>\\g<mag_exp>}")) | ||
FancyNumberFormatter(significant_digits, mult_symbol="\\cdot") = | ||
FancyNumberFormatter("%.$(significant_digits)g", mult_symbol) | ||
|
||
(f::FancyNumberFormatter)(x) = string(x) | ||
|
||
function (f::FancyNumberFormatter)(x::AbstractFloat) | ||
s = @eval @sprintf $(f.fmt) $x | ||
return replace(s, float_regex => f.exponent_format) | ||
end | ||
|
||
(f::FancyNumberFormatter)(x::AbstractFloat) = replace(f.f(x), float_regex => f.exponent_format) | ||
(f::FancyNumberFormatter)(x::Unsigned) = "\\mathtt{0x$(string(x; base=16, pad=2sizeof(x)))}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a7ee6f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
a7ee6f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/102151
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: