How to extend RStudio MathJax to include extensions in "live" notebooks? - rstudio

One of the answers to the StackOverflow question below gives a way of knitting an html page which can use mhchem.js to typeset basic chemistry notation.
How to access MathJax extensions (like siunitx) from Rmarkdown via Pandoc & Knitr?
How can I modify RStudio MathJax to make this rendering happen live in the edited document? Preferably, this extension would just be enabled for all RStudio notebook files for all users of the RStudio Server installation. How can this be accomplished?

I found out this is already built-in once I tell it the magic word:
$$
\require{mhchem}
\ce{H + H -> H_2}
$$
See the MathJax docs:
http://docs.mathjax.org/en/latest/input/tex/extensions/mhchem.html

Related

Preview of math formulars in ASCiiDoc (VS Code)

I am using VS Code to write a document in ASCiiDoc. Part of this document are math formulas.
My problem is that preview of this formulars does not work. For example: If I write
latexmath:[\alpha(t_i)]
the preview is
(\alpha(t_i)).
In Git intepretation of this works, but not locally in preview. How do I fix this?
This problem was discussed in the following GitHub issues:
https://github.com/asciidoctor/asciidoctor-vscode/issues/165
https://github.com/asciidoctor/asciidoctor-vscode/issues/279
The solution appears to be to change the Asciidoc: Change Preview Security Settings to Disable to allow the remote content for the images to load.

Which markup language uses "====="?

i need to understand the following configuration file on github -> https://github.com/GENIVI/vsomeip/blob/master/documentation/vsomeipUserGuide
Unfortunately it is written in a markup language i do not know and can't seem to find elsewhere. Can you tell me which one it is?
This looks like documentation rather than configuration, written in AsciiDoc.
In fact the Build Instructions section tells you what you need:
To build the documentation asciidoc, source-highlight, doxygen and graphviz is needed:
As identified by Gereon, it is AsciiDoc. You can export this file into PDF, HTML and other format.s
If you're using VS Code, Ctrl + SHFT + P (or open Extension Marketplace) and type AsciiDoc. Install the extension. Open the AsciiDoc file, press Ctrl + SHFT + P and type AsciiDoc: Export document as pdf
The opened document will be exported as pdf. It might ask you download another package. Just let it do.

Convert Jupyter notebook to PDF - pdflatex not found on PATH

I'm trying to download my Jupyter notebook as a PDF from the web interface by going to:
File -> Download as -> PDF via LaTeX
However, I get this error:
nbconvert failed: pdflatex not found on PATH
I have both pandoc and MacTex installed. Additionally, in the terminal the pdflatex is set.
$ which pdflatex
/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin/pdflatex
I'm running on Mac OS X El Capitan using Jupyter 4.2.0 with Python 2.7.11
Print it to pdf using your browser (ctrl+p). It is simple and the "you print what you see" approach is great to share a reports/analysis with people that do not code or use the jupyter enviroment. Not publication ready by any means but gets the job done. Just make sure your plots and figures are not on interactive mode otherwise they will not be displayed (set them to %matplotlib inline).
I always had trouble with exporting my jupyter nb to pdf through latex. Quick search and you see that A LOT of people do. I could get some stuff worked out but the formatting was lackluster with code and plots not displayed the way I wanted. I eventually accepted that the jupyter notebook could not produce "publish-ready" pdfs easily. When I want that, I generate plots/figures/code on jupyter and call them on a latex file.
You may want to hide some of your code from the pdf, set the resolution of your plots and add some extensions to improve your jupyter documents.
If you really want to make your publications from inside jupyter, this tutorial has some great tips.
I've had a lot of luck exporting to HTML instead of pdf. HTML is similarly viewable by any non-developers in your organization, assuming they have a browser, and you can make use of some excellent tools like toc2, which gives your viewers a table of contents so they can stay oriented with what they are reading. You can also link to specific sections using the "#" symbol to do header links. Similarly, HTML supports interactive plotting like those available through plotly, so that end-users can zoom into graphs and other figures. Encourage you to give it a shot. Example code with nbconvert below:
jupyter nbconvert --to html --template toc2 --TemplateExporter.exclude_input=True "<path-to-ipynb>"
If its really necessary to have a pdf, you can then open your html in Chrome or Firefox and print to pdf that way. Hope it helps!

Integrated Markdown WYSIWYG text editor

In looking for a straightforward WYSIWYG editor for Markdown code, I am not finding a comparible UI to that of CkEditor, TinyMCE, ect.
Specifically, the Markdown "WYSIWYG" editors that are often recommended (such as posts like this ) are not pure WYSIWYG editors in the sense that users either still write raw Markdown ( MarkItUp ) or go to the other extreme of having in-line editing without standard controls ( Hallo ).
I need something in-between.
I'm looking for a Markdown editor that looks and functions like a stripped down CkEditor text box, and that accepts and outputs Markdown. There should be a toolbar with a minimum set of formatting options (B, I, U, lists, ect), and the text entry area should show the converted Markdown, not the raw code. There should be a Source button that will allow users to edit the raw Markdown, but even that is optional. Ex:
I get the reason for Markdown/wiki, ect - the security it offers. I don't mind entering raw code like here at SE, but my users are not geeks and do not find this enjoyable. They don't want to see * * * ___ and spaces mixed in with their text. They are used to "Word" style editing, and are most productive in that environment.
So - is there a truly integrated WYSIWYG editor for Markdown? I'm writing in a PHP, so something that I can invoke with a class would be perfect.
Sept 23, 2015 Update
CKEditor now has a Markdown addon that does this exact thing. The addon project is hosted on github.
Screenshots:
Apr 13, 2015 Update
Someone professing to develop CKEditor says that the appearance of CommonMark is a game changer, and we could possibly see a proper markup interface for CKEditor (read comments for the full story).
Feb 6, 2015 Update
CKEditor now comes with a plugin that outputs (and accepts as input) BBCode.
Demo: http://ckeditor.com/demo#bbcode
SimpleMDE, a newcomer, may be the answer. I've been searching for something just like this for a month now. I'm surprised that this does not show up higher in search results. I had to go through a notice on lepture/editor to find this.
I was researching in this subject the other day and I haven't found any decent WYSIWYG editor with Markdown output. In fact, first you have to have to create a WYSIWG Markdown editor is WYSIWG HTML editor and there are just few of them that are usable on the market.
There's a chance that you'll be able to create dataProcessor for CKEditor that will change HTML editor into Markdown editor. We've got a plugin for BBCode that works like this (check out http://nightly-v4.ckeditor.com/3737/samples/bbcode.html).
All you have to do is implement this interface http://nightly-v4.ckeditor.com/ckeditor_api/#!/api/CKEDITOR.dataProcessor. If you check BBCode plugin's code you'll see some hacks and tricks, because unfortunately current CKEditor's architecture isn't ready (yet) to create such a data processor. However, I believe that if you want to provide only few styling options you should be able to implement Markdown support pretty quickly.
EDIT Sept 23, 2015
CKEditor now has a Markdown addon that does this exact thing. The addon project is hosted on github.
Screenshots:
As posted in my Feb 6, 2015 update, CKEditor now includes plugins that allow BBCode input and output.
A demo is available here: http://ckeditor.com/demo#bbcode
EDIT Apr 13, 2015:
Someone professing to develop CKEditor says that the appearance of CommonMark is a game changer, and we could possibly see a proper markup interface for CKEditor (read comments for the full story).
Pen is a new (active as of 2014) WYSIWYG editor that outputs Markdown.
It's not perfect—I've had issues with pasting HTML there—but it works.
Edit: Sorry! It doesn't output Markdown. Walery Strauch pointed out in the comments that the Markdown formatting signs I saw were actually CSS pseudo element rules:
Still, I'll leave it here as an option since some people upvoted this answer and it may have been of use to somebody.
I implemented a very simple editor that allows the contents of a <textarea> that contains Markdown to be edited in a WYSIWYG fashion.
I used Hallo. I don't think its web site makes it obvious that it is not itself a Markdown WYSIWYG editor but the demo does forge the path to one.
Hallo allows WYSIWYG editing of the HTML inside a <div>. I used javascript to hide any <textarea> blocks that have a specific wysiwyg CSS class, replacing it with a <div> and copying the contents of the <textarea> into the <div>. The copying runs through Showdown which produces HTML from Markdown.
Another Javascript routine reacts every time the <div> contents change. It copies the contents back into the (now hidden) <textarea>. The content is run through to-markdown to convert from HTML to Markdown.
If the <textarea> is a field in a <form>, then the edited Markdown will be sent to the server when that form is submitted.
The inspiration for this comes from the Hallo Markdown Example, specifically the editor.js file. I used that as a basis for my own script along with hallo.js, showdown.js and to-markdown.js.
My script, wysiwyg.js is a derivative of editor.js from the Hallo Markdown Example. Some points to note:
I use this in a Rails application (not that that matters)
It runs on ready and also on page:load, the latter because Rails uses Turbolinks
It runs on ajaxComplete because I use Ajax for form error reports
There are other dependencies: JQueryUI and Rangy (Rails users can avail of the gems jquery-ui-rails and rangy-rails).
Also Font Awesome is used for the tool bar icons. The version of hallo.js used by the demo is out of date (it uses an old version of Font Awesome) - use hallo.js from GitHub instead.
You only need to add CSS class='wysiwyg' to any <textarea> to enable WYSIWYG on it. The <textarea> should conain Markdown formatted text.
I would expect that wysiwyg.js could be easily adapted to use another editor if you don't like Hallo as long as it works on the HTML in a <div>. There are quite a few to choose from but not all are as lightweight as Hallo.
A smilar piece of work that I found is markdown-html-form. It uses the same Showdown and to-markdown.
I am also looking for a markdown editor that is described at the top of this thread
Have you seen "markdown tools": http://md-wysiwyg.sourceforge.net/
Demo: http://md-wysiwyg.sourceforge.net/cgi-bin/cgi_wysiwyg_test.py/
That seems pretty close to what we are looking for, it does a reasonable job of taking your WYSIWYG rich text and outputting markdown. However it failed on an encoding exception when I pasted in some rich text from a google doc.
I found two which currently seem to be quite popular, active and free but haven't been mentioned yet.
The first one is Toast UI Editor. It supports both modes (WYSIWYG and raw). It has official react and vuejs wrappers.
The second one is ProseMirror which calls itself "a toolkit for building rich-text editors on the web" and it seems to be very flexible and extensive. It also supports both modes.
I'm pretty sure solid unofficial react / vue / angular wrappers for it can be found as well.

Markdown syntax highlighting in SciTE/Notepad++

I'm looking for a .properties file for Markdown syntax in SciTE. Is it possible?
A partial highlighter would do, otherwise.
I'm using this syntax file: https://github.com/leafnode/markdown_npp with some color changes to fit dark background.
I've uploaded my (dark) user-defined language Markdown highlighter on GitHub. It uses different workarounds than thomsmits', which for the style of Markdown I've chosen work better.
Until the Markdown Scintilla lexer is imported into Notepad++, user defined languages are the best we can do.
I don't use Notepad++ any more and have deleted my project. Try Brettz9's fork of the project here: https://github.com/brettz9/Notepad---Markdown-Highlighting
I'm using Markdown-plus-plus. The install instruction is outdated on many projects. The actual instruction is:
Select menu "Language" → "Define your language..."
Press button "Import...", and select {markdown}.xml (from GitHub repositories).
Restart Notepad++
I believe somebody mentioned on the mailing list that he is working on such a lexer.
I don't think a simple .properties file can do the job, as there isn't any existing lexer (to my knowledge) with similar syntax.

Resources