| Author | DaveJarvis <email> |
|---|---|
| Date | 2020-09-17 18:56:02 GMT-0700 |
| Commit | 86fd370af5144c4358f128358236ac3f5e4c02e3 |
| Parent | ec78283 |
| Delta | 19 lines added, 13 lines removed, 6-line increase |
| p, blockquote, ul, ol, dl, table, pre { | ||
| margin: 1em 0; | ||
| - vertical-align: middle; | ||
| } | ||
| * See SVGReplacedElementFactory for details. | ||
| */ | ||
| -svg, tex { | ||
| +tex { | ||
| /* Ensure the formulas can be inlined with text. */ | ||
| display: inline-block; | ||
| +} | ||
| + | ||
| +/* Without a robust typesetting engine, there's no | ||
| + * nice-looking way to automatically typeset equations. | ||
| + * Sometimes baseline is appropriate, sometimes the | ||
| + * descender must be considered, and sometimes vertical | ||
| + * alignment to the middle looks best. | ||
| + */ | ||
| +p tex { | ||
| vertical-align: middle; | ||
| } | ||
| import org.jetbrains.annotations.Nullable; | ||
| -import java.util.HashSet; | ||
| import java.util.Set; | ||
| + | ||
| +import static com.scrivenvar.processors.markdown.tex.TeXNode.HTML_TEX; | ||
| public class TeXNodeRenderer implements NodeRenderer { | ||
| @Override | ||
| public @Nullable Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() { | ||
| - final Set<NodeRenderingHandler<?>> set = new HashSet<>(); | ||
| - set.add( new NodeRenderingHandler<>( | ||
| - TeXNode.class, this::render ) ); | ||
| - | ||
| - return set; | ||
| + return Set.of( new NodeRenderingHandler<>( TeXNode.class, this::render ) ); | ||
| } | ||
| private void render( final TeXNode node, | ||
| final NodeRendererContext context, | ||
| final HtmlWriter html ) { | ||
| - html.tag( "tex" ); | ||
| + html.tag( HTML_TEX ); | ||
| html.raw( node.getText() ); | ||
| - html.closeTag( "tex" ); | ||
| + html.closeTag( HTML_TEX ); | ||
| } | ||
| } | ||
| /** | ||
| - * Updates the status bar to show the given message. | ||
| + * Updates the status bar to show the first line of the given message. | ||
| * | ||
| - * @param s The message to show in the status bar. | ||
| + * @param message The message to show in the status bar. | ||
| */ | ||
| - private static void update( final String s ) { | ||
| + private static void update( final String message ) { | ||
| runLater( | ||
| () -> { | ||
| + final var s = message == null ? "" : message; | ||
| final var i = s.indexOf( '\n' ); | ||
| sStatusBar.setText( s.substring( 0, i > 0 ? i : s.length() ) ); |