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

fix tex. #26

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lib/nbv.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ var nbv = (function() {

// if (st.toc)
// render_toc()

// fixed: postprocessing of tex by nagexiucai
// must do below after [marked](https://github.com/chjj/marked)
// for exsample: render tex by [kates](https://github.com/Khan/KaTeX)
// var maths = document.getElementsByClassName("math");
// for(var i=0; i<maths.length; i++) {
// katex.render(maths[i].getAttribute('tex'), maths[i], {
// displayMode: true,
// macros: {
// '\\RR': '\\mathbb{R}'
// }
// });
// }
}

function excount(cell, tin) {
Expand Down Expand Up @@ -183,6 +196,7 @@ var nbv = (function() {

dm = d.createElement('pre');
dm.style.margin = 0;
dm.className = 'illustration-title'; // fixed: some outputs may be customized hidden, by nagexiucai
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this class referring to?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, maybe i should comment it?

users can make 'display_data' hidden by using the 'illustration-title' like "display: none;", we konw.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd drop it, let the illustration title be seen.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that is good, i can understand, the "illustration-title" is a temporary thing of mine, styles should be managed elsewhere.

dm.textContent = dt.data[fmt].join('');
break;

Expand Down Expand Up @@ -257,7 +271,11 @@ var nbv = (function() {

function handle_mdown(cell) {
var el = d.createElement('div');
el.innerHTML = marked(cell.source.join(''));
// fixed: preprocess tex by nagexiucai
var text = cell.source.join('');
text = text.replace(/\$\$([^\$]+)\$\$/g, function(){return '<p class="math" tex="' + arguments[1] + '"></p>';}) // $$formula$$ with block style given by katex
text = text.replace(/\$([^\$]+)\$/g, function(){return '<p class="math" style="display:inline-block;" tex="' + arguments[1] + '"></p>';}) // $formula$ with inline-block style
el.innerHTML = marked(text);

return el;
}
Expand Down