Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions bundle/latex2html5.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2086,10 +2086,10 @@ var LaTeX2HTML5 = (() => {
return contents;
},
img: matchrepl(/\\img\{([^}]*)\}/, function(m) {
return '<div style="width: 100%;text-align: center;"><img src="' + m[1] + '"></div>';
return '<div class="latex2js-figure"><img src="' + m[1] + '"></div>';
}),
youtube: matchrepl(/\\youtube\{([^}]*)\}/, function(m) {
return '<div style="width: 100%;text-align: center;"><iframe width="560" height="315" src="https://www.youtube.com/embed/' + m[1] + '" frameborder="0" allowfullscreen></iframe></div>';
return '<div class="latex2js-figure"><iframe width="560" height="315" src="https://www.youtube.com/embed/' + m[1] + '" frameborder="0" allowfullscreen></iframe></div>';
}),
href: matchrepl(/\\href\{([^}]*)\}\{([^}]*)\}/, function(m) {
return '<a href="' + m[1] + '">' + m[2] + "</a>";
Expand Down
5 changes: 5 additions & 0 deletions bundle/latex2js.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ svg {
margin: var(--latex2js-parskip) auto;
}

.latex2js-figure {
margin: var(--latex2js-parskip) auto;
text-align: center;
}

.enumerate {
list-style: circle;
padding: 12px;
Expand Down
5 changes: 5 additions & 0 deletions packages/css/latex2js.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ svg {
margin: var(--latex2js-parskip) auto;
}

.latex2js-figure {
margin: var(--latex2js-parskip) auto;
text-align: center;
}

.enumerate {
list-style: circle;
padding: 12px;
Expand Down
5 changes: 5 additions & 0 deletions packages/latex2js/latex2js.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ svg {
margin: var(--latex2js-parskip) auto;
}

.latex2js-figure {
margin: var(--latex2js-parskip) auto;
text-align: center;
}

.enumerate {
list-style: circle;
padding: 12px;
Expand Down
4 changes: 2 additions & 2 deletions packages/latex2js/src/lib/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ export const Functions = {
},
img: matchrepl(/\\img\{([^}]*)\}/, function(m: RegExpMatchArray) {
return (
'<div style="width: 100%;text-align: center;"><img src="' +
'<div class="latex2js-figure"><img src="' +
m[1] +
'"></div>'
);
}),
youtube: matchrepl(/\\youtube\{([^}]*)\}/, function(m: RegExpMatchArray) {
return (
'<div style="width: 100%;text-align: center;"><iframe width="560" height="315" src="https://www.youtube.com/embed/' +
'<div class="latex2js-figure"><iframe width="560" height="315" src="https://www.youtube.com/embed/' +
m[1] +
'" frameborder="0" allowfullscreen></iframe></div>'
);
Expand Down
18 changes: 18 additions & 0 deletions packages/latex2js/test/figure.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import LaTeX2JS from '../src';

const render = (tex: string): string => {
const parsed: any = new LaTeX2JS().parse(tex);
return parsed.map((segment: any) => (segment.lines || []).join('\n')).join('\n');
};

describe('raster figure wrappers', () => {
it.each([
['\\img{figure.png}', '<div class="latex2js-figure"><img src="figure.png"></div>'],
[
'\\youtube{video-id}',
'<div class="latex2js-figure"><iframe width="560" height="315" src="https://www.youtube.com/embed/video-id"',
],
])('uses the figure class for %s', (tex, expected) => {
expect(render(tex)).toContain(expected);
});
});
Loading