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

Work with AsciiMath #71

Open
TianBo-Timothy opened this issue Oct 5, 2016 · 11 comments
Open

Work with AsciiMath #71

TianBo-Timothy opened this issue Oct 5, 2016 · 11 comments

Comments

@TianBo-Timothy
Copy link

Hi, I am in favor of Markdown and AsciiMath. AsciiMath is another javascript that enables something similar to Markdown that allows me to edit formula with text, see http://asciimath.org/. Unfortunately, strapdown and AsciiMath does not work properly together at the moment.

Currently, I can use AsciiMath only outside of <xmp> block, this is not convenient as I also want my text to come with formula.

I am not able to propose a solution. However, I will be grateful if strapdown can solve this issue. So that we can use simple text to write documents with formulas.

@obedm503
Copy link

obedm503 commented Oct 6, 2016

This is not really a solution but more an alternative. You could use bootmark. It doesn't require you to use <xmp> or <textarea>, but still adds bootstrap and a bunch of other stuff. Also, it's in active development, unlike strapdown.

Disclaimer: I am the author of bootmark. ;)

@TianBo-Timothy
Copy link
Author

Hi,

thanks for your suggestion. I tried bootmark this morning. It does not work
as expected yet ...

What I did is like:

<title>any tag - document</title> <script src=" https://obedm503.github.io/bootmark/dist/bootmark.bundle.min.js"></script> <script src=" https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=AM_HTMLorMML "></script>

The first equation: `E = m c^2`

# First block of Markdown text goes in here

The second equation: `E = sum_i m_i c^2`

# Second block of Markdown text goes in here

Both equations are shown. But the second block of markdown text is gone
after rendering. And there is a navigation bar on the top of the page. Can
you give any suggestion to fix it?

Best Regards
Tian, Bo

On Thu, Oct 6, 2016 at 3:53 AM, obedm503 [email protected] wrote:

This is not really a solution but more an alternative. You could use
bootmark https://obedm503.github.io/bootmark/. It doesn't require you
to use <xmp> or <textarea>, but still adds bootstrap and a bunch of other
stuff. Also, it's in active development, unlike strapdown.

Disclaimer: I am the author of bootmark. ;)


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#71 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/APcDePsgKypxWXJiztU7ut4uPzA6pFnRks5qxFSwgaJpZM4KOgkD
.

@obedm503
Copy link

obedm503 commented Oct 6, 2016

as of now, bootmark is intended to work with a single block of markdown, and not different segments with other text in between. The good news is that I'm working on a new version that should fix stuff regarding polyfills, and I could fix your issue in there. I really never thought of that use case (several blocks of markdown instead of one), so thanks for bringing that up. It's a great idea.

As for the navigation bar, you can disable that through config on the element with markdown. You simply need to add

<div id="bootmark" data-html="{ toc: false }">
...some markdown...
</div>

to the element with the id of markdown (remember that id's have to be unique), or add

<bootmark html="{ toc: false }">
...some markdown...
</bootmark>

if your using the <bootmark> element.

toc stands for Table Of Contents.

Now that the idea came up of having multiple separated chunks of markdown, I might consider changin the requirement from id="bootmark" to class="bootmark" to allow for such a thing.

Also, I know that the docs are pretty bad right now, that should also be fixed on the new release.

@TianBo-Timothy
Copy link
Author

So you will become the first to support AsciiMath along with markdown :)

I am also thinking about another approach: can we have some markdown
directly for math, e.g.

$$E = sum_i m_i c^2$$

then you can figure out a way to use MathJax for further processing. In
this way, it will feel more like a native solution.

What do you think ?

B.R.
Tian, Bo

On Fri, Oct 7, 2016 at 1:58 AM, obedm503 [email protected] wrote:

as of now, bootmark is intended to work with a single block of markdown,
and not different segments with other text in between. The good news is
that I'm working on a new version that should fix stuff regarding
polyfills, and I could fix your issue in there. I really never thought of
that use case (several blocks of markdown instead of one), so thanks for
bringing that up. It's a great idea.

As for the navigation bar, you can disable that through config on the
element with markdown. You simply need to add

...some markdown...

to the element with the id of markdown (remember that id's have to be
unique
http://stackoverflow.com/questions/7262195/several-elements-with-the-same-id-responding-to-one-css-id-selector),
or add

...some markdown...

if your using the element.

toc stands for Table Of Contents.

Now that the idea came up of having multiple separated chunks of markdown,
I might consider changin the requirement from id="bootmark" to
class="bootmark" to allow for such a thing.

Also, I know that the docs are pretty bad right now, that should also be
fixed on the new release.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#71 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/APcDeIH5C-IGElUOpacJgyo7UMrdBYoMks5qxYsPgaJpZM4KOgkD
.

@TianBo-Timothy
Copy link
Author

So you will become the first to support AsciiMath along with markdown :)

I am also thinking about another approach: can we have some markdown
directly for math, e.g.

$$E = sum_i m_i c^2$$

then you can figure out a way to use MathJax for further processing. In
this way, it will feel more like a native solution.

What do you think ?

B.R.

On Fri, Oct 7, 2016 at 1:58 AM, obedm503 [email protected] wrote:

as of now, bootmark is intended to work with a single block of markdown,
and not different segments with other text in between. The good news is
that I'm working on a new version that should fix stuff regarding
polyfills, and I could fix your issue in there. I really never thought of
that use case (several blocks of markdown instead of one), so thanks for
bringing that up. It's a great idea.

As for the navigation bar, you can disable that through config on the
element with markdown. You simply need to add

...some markdown...

to the element with the id of markdown (remember that id's have to be
unique
http://stackoverflow.com/questions/7262195/several-elements-with-the-same-id-responding-to-one-css-id-selector),
or add

...some markdown...

if your using the element.

toc stands for Table Of Contents.

Now that the idea came up of having multiple separated chunks of markdown,
I might consider changin the requirement from id="bootmark" to
class="bootmark" to allow for such a thing.

Also, I know that the docs are pretty bad right now, that should also be
fixed on the new release.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#71 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/APcDeIH5C-IGElUOpacJgyo7UMrdBYoMks5qxYsPgaJpZM4KOgkD
.

@obedm503
Copy link

obedm503 commented Oct 8, 2016

though it would be cool, adding a custom code block language might be overkill. (is it even possible?) You could use normal E = sum_i m_i c^2 syntax and disabling prettyprint. (prettyprint might mess up the math.) does asciimath allow for multiline math blocks? something like:

`
E = sum_i m_i c^2
`

I figured out how to use multiple bootmark elements/markdown blocks per page. This is still not on the latest stable release.

I'll look into having a custom code block language

@obedm503
Copy link

after digging through MathJax's documentation I couln't find a simple method which would take a string of math and return html. So I looked for alternatives, and the internet gave me KaTeX. It does just what I wanted, and is alot faster than mathjax.

so, like you suggested, I created an extension for showdown (the parser used by bootmark) that uses katex to convert "latex code" to pretty math.

the syntax works like you suggested it should but instead of

```math
some math here
```

it uses

```latex
some math here
```

since the "code" is in latex.

For a demo of the extension check this https://obedm503.github.io/katex-latex/
that page is built from multiple elements. some with markdown outside and some with markdown inside. Shared config is defined in the <script> tag in the head of the document. Shared config is something new to version 0.5.0 of bootmark.

if you still need to use asciimath, it seems there are ways to convert asciimath to latex which would then be converted by the extension but it's not clear how to accomplish that. I'll look into this tho.

TL;DR: katex-latex is a showdown extension for latex math in markdown. MathJax is slow, and KaTeX is fast (really fast compared to mathjax) with the tradeoff of latex instead of asciimath.

what do you think of the use of latex instead of math ?

@TianBo-Timothy
Copy link
Author

It is certainly cool to be able to use Latex in Markdown. But it’s still better to use AsciiMath. The idea is to save time of writing (time of parsing is not a big issue here)

There is a Latex package called asciimth (https://github.com/judah/asciimath-tex). It is old but it works. It use similar syntax to write math. Is it possible to use this package along with KaTeX?

From: obedm503
Sent: Monday, October 10, 2016 5:50 AM
To: arturadib/strapdown
Cc: TianBo-Timothy ; Author
Subject: Re: [arturadib/strapdown] Work with AsciiMath (#71)

after digging through MathJax's documentation I couln't find a simple method which would take a string of math and return html. So I looked for alternatives, and the internet gave me KaTeX. It does just what I wanted, and is alot faster than mathjax.

so, like you suggested, I created an extension for showdown (the parser used by bootmark) that uses katex to convert "latex code" to pretty math.

the syntax works like you suggested it should but instead of

$$some math here$$

it uses

some math here

since the "code" is in latex.

For a demo of the extension check this https://obedm503.github.io/katex-latex/
that page is built from multiple elements. some with markdown outside and some with markdown inside. Shared config is defined in the <script> tag in the head of the document. Shared config is something new to version 0.5.0 of bootmark.

if you still need to use asciimath, it seems there are ways to convert asciimath to latex which would then be converted by the extension but it's not clear how to accomplish that. I'll look into this tho.

TL;DR: katex-latex is a showdown extension for latex math in markdown. MathJax is slow, and KaTeX is fast (really fast compared to mathjax) with the tradeoff of latex instead of asciimath.

what do you think of the use of latex instead of math ?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@obedm503
Copy link

obedm503 commented Oct 10, 2016

turns out it wasn't so complex to add asciimath support.

check this for an example https://obedm503.github.io/katex-latex/ and it's source

the example builds the webpage from 2 markdown files (README.md and CHANGELOG.md) and some inline markdown (the second <bootmark> element), uses both the <bootmark> element and a div with class="bootmark", uses both latex and asciimath, uses a different code prettify theme than the default, and defines global config for all elements to use.

It is the finest of bootmark + math examples.

Let me know what you think.

@TianBo-Timothy
Copy link
Author

TianBo-Timothy commented Oct 10, 2016 via email

@obedm503
Copy link

just glad I could help

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

No branches or pull requests

2 participants