Giter Club home page Giter Club logo

Comments (14)

marhop avatar marhop commented on July 20, 2024 1

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.

from pandoc-unicode-math.

marhop avatar marhop commented on July 20, 2024 1

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.

from pandoc-unicode-math.

marhop avatar marhop commented on July 20, 2024

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!

from pandoc-unicode-math.

gandalfsaxe avatar gandalfsaxe commented on July 20, 2024

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$"?

from pandoc-unicode-math.

marhop avatar marhop commented on July 20, 2024

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 $A ∧ A$ ..." becomes "The formula $A \land A$ ...", but "The formula A ∧ A ..." does not change.

I have been thinking about replacing symbols outside math environments as well so that the second example would become "The formula A $\land$ A ..." but I am not sure since this would apply to e.g. regular greek text as well which might be surprising in some circumstances.

from pandoc-unicode-math.

marhop avatar marhop commented on July 20, 2024

Hi @gandalfsaxe, I added binaries for Pandoc 2 on Linux and Windows to the release section. Have fun ;-)

from pandoc-unicode-math.

gandalfsaxe avatar gandalfsaxe commented on July 20, 2024

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 $[X]$. This is because I use Typora as my preferred Markdown writing editor, and it supports inline preview of all math blocks very nicely. So while I do need to type some extra to input the latex syntax symbols, at leat the view is nice. Another editor that nicely preview math is Caret. However, pdflatex give an error if I try to convert the markdown file to tex/PDF via pandoc. I've also tried the xelatex engine with no luck. This is the real reason for my need of this filter.

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 😄

from pandoc-unicode-math.

gandalfsaxe avatar gandalfsaxe commented on July 20, 2024

I built it from source using your instructions, but for some reason it can't find the executable:

image

Even though it's in my path:

image

Any suggestions?

from pandoc-unicode-math.

marhop avatar marhop commented on July 20, 2024

Is the /Users/gandalf/.local/bin/pandoc-unicode-math file executable? I get a simliar error when it is not.

from pandoc-unicode-math.

gandalfsaxe avatar gandalfsaxe commented on July 20, 2024

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?

from pandoc-unicode-math.

marhop avatar marhop commented on July 20, 2024

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$".

from pandoc-unicode-math.

gandalfsaxe avatar gandalfsaxe commented on July 20, 2024

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 $...$ everywhere, which will show up nicely en Typora anyway. But of course it's editor specific, so this filter is still very useful for someone not using Typora.

from pandoc-unicode-math.

marhop avatar marhop commented on July 20, 2024

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.

from pandoc-unicode-math.

gandalfsaxe avatar gandalfsaxe commented on July 20, 2024

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 :-)

from pandoc-unicode-math.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.