Closed thriveth closed 10 years ago
Yes, it is possible but it is not that simple.
Actually you can specify the program for converting the text, that means you can specify the flags to pandoc like
let g:shareboard_command = "pandoc -Ss --toc -m -t html"
However, it might not work for MathJax. MathJax use javascript to produce a math formula and currently shareboard does not support javascript because of my limited knowledge for PyQt. But I totally agree with you suggestion, so I'll try to improve this.
Ah, I totally forgot to tell about --webtex
option.
sharboard works correctly with --webtex
option.
The below is what I use for shareboard.
#!/usr/bin/env bash
CSS="$HOME/.vim/misc/shareboard/css/main.css"
BIB="$HOME/Documents/Mendeley/library.bib"
if [ -f "$BIB" ]; then
BIBLIOGRAPHY=" --bibliography='$BIB'"
else
BIBLIOGRAPHY=""
fi
TEXT=`cat /dev/stdin`
# convert with pandoc
TEXT=`echo -nE "$TEXT" | pandoc -f $1 -sS --toc --webtex -c "$CSS" $BIBLIOGRAPHY 2>/dev/null`
#TEXT=`echo "$TEXT" | pandoc -f $1 -sS --toc --webtex -c "$CSS" $BIBLIOGRAPHY`
# modify the text before convert
TEXT=`echo -nE "$TEXT" | perl -pe "s!((?:\d+\s)|/)u([mNMgL]\b)!\1\μ\2!g"`
TEXT=`echo -nE "$TEXT" | perl -pe "s!((?:\d+\s)|/)u(mol\b)!\1\μ\2!g"`
TEXT=`echo -nE "$TEXT" | perl -pe 's/(\d+\s)C\b/\1\&celsius;/g'`
TEXT=`echo -nE "$TEXT" | perl -pe 's/(\d+\s)A\b/\1\&angstrom;/g'`
TEXT=`echo -nE "$TEXT" | perl -pe 's/\&celsius;/\°C/g'`
TEXT=`echo -nE "$TEXT" | perl -pe 's/\&angstrom;/\Å/g'`
echo -nE "$TEXT"
And I use the script above like: https://github.com/lambdalisue/vim-castle/blob/master/home/.vim/vimrc.neobundle#L831
WebTeX looks great for now!
I do not quite understand though - the script above s the one you call command.sh
which you then call from your .vimrc like linked below it...?
That's good :-)
Well I use the shell script to replace "10 uM" to "10 μM" or "&angstrom;" to "Å" after pandoc conversion for convenience.
You can see the documentation at https://github.com/lambdalisue/shareboard.vim#replace-text-before-pandoc (it said 'before' but I found that 'after' is better for this usage)
...But to simply use WebTeX with ShareBoard, what should I do? (I am going to convert the final document to LaTeX anyway, so it shouldn't be too fancy, but some math rendering of sorts would be very nice for a readable preview).
then simply specify the command like
let g:shareboard_command = "pandoc -sS --toc -m html --webtex"
in your vimrc.
From README
g:shareboard_command Specify the compile command. Default is pandoc -Ss --toc -m -t html
Hmm... It doesn't change anything...
Well in my case, it works like this.
Are you sure the g:shareboard_command
is set as pandoc -sS --toc -m html --webtex
?
And are you sure you are using latest Shareboard and shareboard.vim?
P.S.
I'm using pandoc 1.12.0.2 which is located in ~/.cabal/bin
and I add the directory to $PATH
in ~/.vimrc
like
let $PATH=expand("~/.cabal/bin").":".$PATH
I am using pandoc 1.12.1, also form Cabal, and latest Shareboard and shareboard.vim. I even use the same desktop wallpaper as you! :smile:
However, by reading the pandoc help I found out that by changin -m
to -t
in your suggested command:
let g:shareboard_command="pandoc -Ss --toc --webtex -t html"
...then it works just fine.
...Maybe an idea to ad --webtex
to the default command?
Oops, you are right. -m
is option for latexmathml and might conflict with --webtex
option.
I was writing my thesis so my eyes were too tired to find mistake even I posted default option and it definitely say -t
is the option for specifying html
...
Sorry for making you confuse. And yeah, I'll add --webtex
instead of -m
for default.
No problem! Thanks for writing Shareboard and making it available!
I add --webtex
to the default command :-)
This is a feature request to include MathJax redering of \LaTeX math to the view in Shareboard. I like Shareboard a lot, but writing mostly scientific texts, I use a lot of math notation. Pandoc has built/in MathJax support, so it should be possible to include in shareboard fairly easily, I guess, maybe by passing the correct flag to pandoc when running ?