Installation? + Replace symbols in regular strings (outside math environments)
gandalfsaxe opened this issue · 14 comments
Silly question, how do I install this filter?
I updated the README file with installation/usage and build instructions and added a little example file. Hope that helps? I also published a binary that's compatible with Pandoc 1.17 which I happen to use because it comes with Debian 9. Let me know if you need something else!
Great, thanks!
Hmm I do need it to work with pandoc 2.x.x, I'll let you know if it works.
Btw, does it replace e.g. "∧" with "\land" or "$\land$"?
You're welcome, I will be glad to hear about Pandoc 2.x.x!
It replaces symbols like "∧" with "\land" (no added dollar signs), but only inside math environments: "The formula
I have been thinking about replacing symbols outside math environments as well so that the second example would become "The formula A
Hi @gandalfsaxe, I added binaries for Pandoc 2 on Linux and Windows to the release section. Have fun ;-)
Hi again,
Actually having thought about it, my only use for this filter is if it replace a selection of math symbols [X] in the text for
Could you make a version / options / switch that will add the dollar signs around the symbols? As for the possible issue with greek letters, I'm thinking that since you Haskell script is pretty understandable, the user could simply modify it and build from source if needed? The best option may be two separate versions of the filter, one adding dollars signs around symbols and the other not, or even better perhaps an option flag to the filter?
Sorry if I'm asking a lot, but it would be very useful 😄
Is the /Users/gandalf/.local/bin/pandoc-unicode-math
file executable? I get a simliar error when it is not.
Huh it runs now. It looked like it was executable before (did a ls -la
), but I did a chmod 755 pandoc-unicode-math
, and it works now.
In trying to do what I mentioned before, I tried changing:
sym '¬' = "\\neg"
to
sym '¬' = "$\\neg$"
However it only works within math environment, which is obviously not what I want. What else do I need to change so that the substitution are done outside of math blocks?
Hmm, that turns out to be a little more complicated than I initially thought. I am working on it and hope to have some results by the weekend.
OK, I started a new branch where symbols outside math blocks are replaced as well. It still needs a little polish but it should already do what you want. Feedback is very welcome!
Of course this is primarily useful for single characters. Formulas that you want displayed as one coherent math expression still need an explicit math environment because otherwise there is no way to tell where the formula starts and ends. Examples:
- "The variable α holds" now becomes "The variable
$\alpha$ holds". - "The formula A ∧ B" now becomes "The formula A
$\land$ B", but not "The formula$A \land B$ ".
Hi,
I tried converting a .md file with this line into .tex with pandoc:
Testing this is A ∧ B testing.
and this was the result:
Testing this is A \(\land\) B testing.
Shouldn't it be Testing this is A $\land\$ B testing.
? But converting to PDF didn't give an error and gave the correct output as far as I can tell. It may be working as intended, I'm just not sure what \(\land\)
means in TeX? 😅
Anyway I think that using Typora and it's live inline math preview + math block preview box actually solves most of this issue for me after all. So an alternative to this filter would just be to suck it up and use inline
OK, then I will close this issue since it is solved one way or the other ;-)
The \(...\)
vs. $...$
syntax is a Latex vs. Tex thing, see https://en.wikibooks.org/wiki/LaTeX/Mathematics#Mathematics_environments. For practical purposes it seems to be equivalent and since you're writing Markdown not Latex you can certainly keep using $...$
but \(...\)
being "correct" Latex syntax I think Pandoc normalizes this for math environments.
Ah ok. So is it that your filter just tells pandoc to convert X into X in a math environment, and then it's pandoc that decides whether that means \(...\)
or $...$
?
Anyway thanks for your time, it's good to know that both versions of this filter exists and have in the toolbelt. This issue can be closed now yes :-)
Yup. Under the hood, it boils down to "abstract syntax" and "concrete syntax". Pandoc filters modify the so-called abstract syntax tree (AST) of a document and don't care about a specific format's concrete syntax like whether to use $
or \(
or even something completely different to denote the beginning of a math environment.