├── LICENSE.txt ├── README.md ├── pom.xml ├── screenshot.png └── src └── main └── java └── com └── nilhcem └── md2html ├── App.java ├── console ├── ArgsParser.java ├── ConsoleMode.java ├── DisplayUsageException.java └── package-info.java ├── gui ├── InputPane.java ├── MainFrame.java ├── MainPanel.java ├── MenuBar.java ├── PreviewPane.java └── package-info.java └── package-info.java /LICENSE.txt: -------------------------------------------------------------------------------- 1 | * Copyright (c) 2011, Gautier MECHLING 2 | * All rights reserved. 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are met: 5 | * 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of the original author nor the 12 | * names of its contributors may be used to endorse or promote products 13 | * derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY 19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Markdown2HTML 2 | ============= 3 | 4 | An extremely simple Markdown to HTML converter, 5 | powered by [MarkdownJ](http://code.google.com/p/markdownj/). 6 | 7 | Available in command line and GUI mode. 8 | 9 | It is licensed under the BSD license. 10 | 11 | 12 | Requirements 13 | ------------ 14 | 15 | You need Java JVM 1.6 or newer installed on your machine. 16 | 17 | 18 | Usage 19 | ----- 20 | 21 | ### GUI version ### 22 | 23 | `java -jar Markdown2HTML.jar` 24 | 25 | ### Command line version ### 26 | 27 | `java -jar Markdown2HTML.jar markdownFile [- header headerFile.html] [-footer footerFile.html] [-out [file.html]]` 28 | 29 | #### Options for the command line version #### 30 | 31 | - `markdownFile`: the text file which will be converted (compulsory field). 32 | - `-header headerFile.html`: the path of an existing HTML header file. 33 | Its content will be prepended to the converted `markdownFile` file. 34 | - `-footer footerFile.html`: the path of an existing HTML footer file. 35 | Its content will be appended to the converted `markdownFile` file. 36 | - `-out`: enter this to specify that the program should create a new file 37 | which contains the same name as the `markdownFile`, with the .html extension. 38 | - `-out file.html`: enter this to specify the name of the converted file. 39 | 40 | 41 | GUI Screenshot 42 | -------------- 43 | 44 | 45 | 46 | 47 | Building it 48 | ----------- 49 | 50 | `mvn package`, that's all! 51 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.nilhcem 6 | markdown2html 7 | 1.0-SNAPSHOT 8 | jar 9 | 10 | markdown2html 11 | http://maven.apache.org 12 | 13 | 14 | UTF-8 15 | 16 | 17 | 18 | 19 | 20 | com.miglayout 21 | miglayout 22 | 3.7.4 23 | swing 24 | 25 | 26 | 27 | 28 | org.markdownj 29 | markdownj 30 | 0.3.0-1.0.2b4 31 | 32 | 33 | 34 | 35 | commons-io 36 | commons-io 37 | 2.0.1 38 | 39 | 40 | 41 | 42 | Markdown2HTML-${project.version} 43 | 44 | 45 | 46 | 47 | org.apache.maven.plugins 48 | maven-compiler-plugin 49 | 2.3.2 50 | 51 | 1.6 52 | 1.6 53 | 54 | 55 | 56 | 57 | 58 | org.apache.maven.plugins 59 | maven-assembly-plugin 60 | 2.2.1 61 | 62 | 63 | jar-with-dependencies 64 | 65 | 66 | 67 | com.nilhcem.md2html.App 68 | 69 | 70 | 71 | false 72 | 73 | 74 | 75 | 76 | attached 77 | 78 | package 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | nilhcem 89 | Gautier MECHLING 90 | 91 | developer 92 | 93 | +8 94 | 95 | 96 | 97 | 98 | 99 | 100 | BSD 101 | LICENSE.txt 102 | 103 | 104 | 105 | 106 | 107 | 108 | scala-tools 109 | http://scala-tools.org/repo-releases 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nilhcem/markdown2html/ff332f97ef7ad090687debc5c69734e97e1de23f/screenshot.png -------------------------------------------------------------------------------- /src/main/java/com/nilhcem/md2html/App.java: -------------------------------------------------------------------------------- 1 | package com.nilhcem.md2html; 2 | 3 | import java.awt.EventQueue; 4 | import java.io.FileNotFoundException; 5 | import javax.swing.UIManager; 6 | import com.nilhcem.md2html.console.ArgsParser; 7 | import com.nilhcem.md2html.console.ConsoleMode; 8 | import com.nilhcem.md2html.console.DisplayUsageException; 9 | import com.nilhcem.md2html.gui.MainFrame; 10 | 11 | /** 12 | * Entry point of the application. 13 | * 14 | * @author Nilhcem 15 | * @since 1.0 16 | */ 17 | public final class App { 18 | private App() {} 19 | 20 | /** 21 | * Launches the program in command line or using a GUI. 22 | *

23 | * If the program is launched in GUI mode, sets some properties for a better look and feel integration. 24 | *

25 | * 26 | * @param args a list of arguments. 27 | */ 28 | public static void main(String[] args) { 29 | try { 30 | ArgsParser params = new ArgsParser(); 31 | params.checkArgs(args); 32 | 33 | if (params.isConsoleMode()) { // Command line 34 | new ConsoleMode().process(params); 35 | } else { // GUI 36 | EventQueue.invokeLater(new Runnable() { 37 | @Override 38 | public void run() { 39 | System.setProperty("apple.laf.useScreenMenuBar", "true"); 40 | System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Markdown editor"); 41 | UIManager.put("swing.boldMetal", Boolean.FALSE); 42 | try { 43 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 44 | } catch (Exception e) { 45 | System.err.println("error: " + e.getMessage()); 46 | e.printStackTrace(); 47 | } 48 | new MainFrame(); 49 | } 50 | }); 51 | } 52 | } catch (DisplayUsageException e) { 53 | System.err.println(e.getMessage()); 54 | } catch (FileNotFoundException e) { 55 | System.err.println(String.format("File not found: %s", e.getMessage())); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/nilhcem/md2html/console/ArgsParser.java: -------------------------------------------------------------------------------- 1 | package com.nilhcem.md2html.console; 2 | 3 | import java.awt.GraphicsEnvironment; 4 | import java.io.FileNotFoundException; 5 | import org.apache.commons.io.FilenameUtils; 6 | 7 | /** 8 | * Program arguments parser. 9 | * 10 | * @author Nilhcem 11 | * @since 1.0 12 | */ 13 | public final class ArgsParser { 14 | private String markdownFile = null; 15 | private String outputFile = null; 16 | private String headerFile = null; 17 | private String footerFile = null; 18 | private boolean consoleMode = GraphicsEnvironment.isHeadless(); 19 | 20 | /** 21 | * Checks arguments and determine the running mode (command line or GUI). 22 | *

23 | *

28 | *

29 | * 30 | * @param args a list of arguments sent while launching the program. 31 | * @throws DisplayUsageException if arguments are wrong. 32 | * @throws FileNotFoundException if the file to open in command line was not found. 33 | */ 34 | public void checkArgs(String[] args) throws DisplayUsageException, FileNotFoundException { 35 | boolean specifyOutput = false; 36 | boolean specifyHeader = false; 37 | boolean specifyFooter = false; 38 | 39 | for (String arg : args) { 40 | if ("-usage".equals(arg) || "-h".equals(arg) || "-help".equals(arg)) { 41 | throw new DisplayUsageException(); 42 | } else if (specifyHeader && headerFile == null) { 43 | headerFile = arg; 44 | specifyHeader = false; 45 | } else if (specifyFooter && footerFile == null) { 46 | footerFile = arg; 47 | specifyFooter = false; 48 | } else if (specifyOutput && outputFile == null) { 49 | outputFile = arg; 50 | specifyOutput = false; 51 | } else { 52 | if ("-out".equals(arg)) { 53 | specifyOutput = true; 54 | } else if ("-header".equals(arg)) { 55 | specifyHeader = true; 56 | } else if ("-footer".equals(arg)) { 57 | specifyFooter = true; 58 | } else if (markdownFile == null) { 59 | markdownFile = arg; 60 | } else { 61 | throw new DisplayUsageException(); 62 | } 63 | } 64 | } 65 | 66 | if (consoleMode && markdownFile == null) { 67 | throw new DisplayUsageException(); 68 | } 69 | if (specifyOutput && outputFile == null) { 70 | outputFile = FilenameUtils.removeExtension(markdownFile) + ".html"; 71 | } 72 | 73 | // may run console mode even if there is a graphic environment 74 | consoleMode = (markdownFile != null || outputFile != null); 75 | } 76 | 77 | /** 78 | * Returns the name of the markdown file (the file in input). 79 | * 80 | * @return the name of the markdown file (the file in input). 81 | */ 82 | public String getMarkdownFile() { 83 | return markdownFile; 84 | } 85 | 86 | /** 87 | * Returns the name of the HTML file (the file in output). 88 | * 89 | * @return the name of the HTML file (the file in output). 90 | */ 91 | public String getOutputFile() { 92 | return outputFile; 93 | } 94 | 95 | /** 96 | * Returns {@code true} if the program should be launched in console mode (command line), or {@code false} for a GUI mode. 97 | * 98 | * @return {@code true} if the program should be launched in console mode (command line), or {@code false} for a GUI mode. 99 | */ 100 | public boolean isConsoleMode() { 101 | return consoleMode; 102 | } 103 | 104 | /** 105 | * Returns the name of the header file if any, or {@code null} if none was specified. 106 | * 107 | * @return the name of the header file if any, or {@code null} if none was specified. 108 | */ 109 | public String getHeaderFile() { 110 | return headerFile; 111 | } 112 | 113 | /** 114 | * Returns the name of the footer file if any, or {@code null} if none was specified. 115 | * 116 | * @return the name of the footer file if any, or {@code null} if none was specified. 117 | */ 118 | public String getFooterFile() { 119 | return footerFile; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/com/nilhcem/md2html/console/ConsoleMode.java: -------------------------------------------------------------------------------- 1 | package com.nilhcem.md2html.console; 2 | 3 | import java.io.File; 4 | import java.io.FileNotFoundException; 5 | import java.io.IOException; 6 | import org.apache.commons.io.FileUtils; 7 | import com.petebevin.markdown.MarkdownProcessor; 8 | 9 | /** 10 | * Converts the markdown file in a HTML file when the application is running in command line. 11 | * 12 | * @author Nilhcem 13 | * @since 1.0 14 | */ 15 | public final class ConsoleMode { 16 | private final MarkdownProcessor processor = new MarkdownProcessor(); 17 | 18 | /** 19 | * Converts the file in HTML depending on the options sent in parameter. 20 | * 21 | * @param args an ArgsParser object containing the program's options. 22 | * @throws FileNotFoundException if the file which should be converted doesn't exist. 23 | */ 24 | public void process(ArgsParser args) throws FileNotFoundException { 25 | File file = new File(args.getMarkdownFile()); 26 | if (!file.exists()) { 27 | throw new FileNotFoundException(args.getMarkdownFile()); 28 | } 29 | 30 | try { 31 | String fileContent = FileUtils.readFileToString(file, "UTF-8"); 32 | String htmlContent = getFileContent(args.getHeaderFile()) + processor.markdown(fileContent) + getFileContent(args.getFooterFile()); 33 | 34 | if (args.getOutputFile() == null) { 35 | // Display to console 36 | System.out.println(htmlContent); 37 | } 38 | else { 39 | // Save to file 40 | File output = new File(args.getOutputFile()); 41 | FileUtils.write(output, htmlContent, "UTF-8"); 42 | } 43 | } 44 | catch (IOException e) { 45 | System.err.println("ERROR"); 46 | e.printStackTrace(); 47 | } 48 | } 49 | 50 | /** 51 | * Returns the content of the file in parameter (should be an HTML file), or an empty String if the file is {@code null}. 52 | *

53 | * This method is useful to include header and footers. 54 | *

55 | * 56 | * @param filePath the file which should be opened and converted. The file is usually a header or a footer. 57 | * @return the content of the file in parameter, or an empty String if the file is {@code null} or if an error happened. 58 | * @throws FileNotFoundException if the file specified in parameter doesn't exist. 59 | */ 60 | private String getFileContent(String filePath) throws FileNotFoundException { 61 | if (filePath != null) { 62 | File file = new File(filePath); 63 | if (!file.exists()) { 64 | throw new FileNotFoundException(filePath); 65 | } 66 | 67 | try { 68 | return FileUtils.readFileToString(file, "UTF-8"); 69 | } 70 | catch (IOException e) { 71 | System.err.println(String.format("Error parsing file: %s", filePath)); 72 | } 73 | } 74 | return ""; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/nilhcem/md2html/console/DisplayUsageException.java: -------------------------------------------------------------------------------- 1 | package com.nilhcem.md2html.console; 2 | 3 | /** 4 | * Thrown if the program arguments were invalid. 5 | * 6 | * @author Nilhcem 7 | * @since 1.0 8 | */ 9 | public final class DisplayUsageException extends Exception { 10 | private static final long serialVersionUID = -7009963711233684636L; 11 | 12 | /** 13 | * Displays the program usage. 14 | */ 15 | @Override 16 | public String getMessage() { 17 | return "usage: java -jar Markdown2HTML.jar [markdownFile] [- header headerFile.html] [-footer footerFile.html] [-out [file.html]]"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/nilhcem/md2html/console/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes used while running the program in command line. 3 | */ 4 | package com.nilhcem.md2html.console; 5 | -------------------------------------------------------------------------------- /src/main/java/com/nilhcem/md2html/gui/InputPane.java: -------------------------------------------------------------------------------- 1 | package com.nilhcem.md2html.gui; 2 | 3 | import java.awt.event.KeyEvent; 4 | import java.awt.event.KeyListener; 5 | import java.util.Observable; 6 | import javax.swing.JScrollPane; 7 | import javax.swing.JTextArea; 8 | 9 | /** 10 | * Scrolled text area where will be inputed markdown data to be converted. 11 | * 12 | * @author Nilhcem 13 | * @since 1.0 14 | */ 15 | public final class InputPane extends Observable { 16 | private final JScrollPane inputPane = new JScrollPane(); 17 | private final JTextArea inputTextArea = new JTextArea(); 18 | 19 | /** 20 | * Creates the text area and add a key listener to call observer every time a key is released. 21 | */ 22 | public InputPane() { 23 | inputPane.getViewport().add(inputTextArea, null); 24 | inputTextArea.addKeyListener(new KeyListener() { 25 | @Override 26 | public void keyTyped(KeyEvent e) { 27 | } 28 | @Override 29 | public void keyReleased(KeyEvent e) { 30 | setChanged(); 31 | notifyObservers(inputTextArea.getText()); 32 | } 33 | @Override 34 | public void keyPressed(KeyEvent e) { 35 | } 36 | }); 37 | } 38 | 39 | /** 40 | * Returns the JScrollPane object. 41 | * 42 | * @return the JScrollPane object. 43 | */ 44 | public JScrollPane get() { 45 | return inputPane; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/nilhcem/md2html/gui/MainFrame.java: -------------------------------------------------------------------------------- 1 | package com.nilhcem.md2html.gui; 2 | 3 | import java.awt.Dimension; 4 | import javax.swing.JFrame; 5 | 6 | /** 7 | * Provides the main window of the application. 8 | * 9 | * @author Nilhcem 10 | * @since 1.0 11 | */ 12 | public final class MainFrame { 13 | private final JFrame mainFrame = new JFrame("Markdown editor"); 14 | private final MenuBar menu = new MenuBar(); 15 | private final MainPanel panel = new MainPanel(); 16 | 17 | /** 18 | * Creates the main window and makes it visible. 19 | */ 20 | public MainFrame() { 21 | Dimension frameSize = new Dimension(640, 440); 22 | 23 | mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 24 | mainFrame.setSize(frameSize); 25 | mainFrame.setMinimumSize(frameSize); 26 | 27 | mainFrame.setJMenuBar(menu.get()); 28 | mainFrame.getContentPane().add(panel.get()); 29 | mainFrame.setLocationRelativeTo(null); // Center main frame 30 | mainFrame.setVisible(true); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/nilhcem/md2html/gui/MainPanel.java: -------------------------------------------------------------------------------- 1 | package com.nilhcem.md2html.gui; 2 | 3 | import javax.swing.JPanel; 4 | import net.miginfocom.swing.MigLayout; 5 | 6 | /** 7 | * Provides the main panel of the application, which will contain all the components. 8 | * 9 | * @author Nilhcem 10 | * @since 1.0 11 | */ 12 | public final class MainPanel { 13 | private final MigLayout layout = new MigLayout( 14 | "", // Layout constraints 15 | "[fill,50%] 10 [fill,50%]", // Column constraints 16 | "[grow,fill]"); // Row constraints 17 | private final JPanel mainPanel = new JPanel(layout); 18 | 19 | private final InputPane input = new InputPane(); 20 | private final PreviewPane preview = new PreviewPane(); 21 | 22 | /** 23 | * Creates the main panel, adding observer to the input and building the GUI. 24 | */ 25 | public MainPanel() { 26 | // Add observer 27 | input.addObserver(preview); 28 | 29 | // Build GUI 30 | mainPanel.add(input.get()); 31 | mainPanel.add(preview.get()); 32 | } 33 | 34 | /** 35 | * Returns the JPanel object. 36 | * 37 | * @return the JPanel object. 38 | */ 39 | public JPanel get() { 40 | return mainPanel; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/nilhcem/md2html/gui/MenuBar.java: -------------------------------------------------------------------------------- 1 | package com.nilhcem.md2html.gui; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | import java.util.Observable; 6 | import javax.swing.JMenu; 7 | import javax.swing.JMenuBar; 8 | import javax.swing.JMenuItem; 9 | import javax.swing.JOptionPane; 10 | 11 | /** 12 | * Provides the menu bar of the application. 13 | * 14 | * @author Nilhcem 15 | * @since 1.0 16 | */ 17 | public final class MenuBar extends Observable { 18 | private final JMenuBar menuBar = new JMenuBar(); 19 | 20 | /** 21 | * Creates the menu bar and the different menus (file / edit / help). 22 | */ 23 | public MenuBar() { 24 | menuBar.add(createFileMenu()); 25 | menuBar.add(createHelpMenu()); 26 | } 27 | 28 | /** 29 | * Returns the JMenuBar object. 30 | * 31 | * @return the JMenuBar object. 32 | */ 33 | public JMenuBar get() { 34 | return menuBar; 35 | } 36 | 37 | /** 38 | * Creates the file menu. 39 | *

40 | * The file menu contains an "Exit" item, to quit the application. 41 | *

42 | * 43 | * @return the newly created file menu. 44 | */ 45 | private JMenu createFileMenu() { 46 | JMenu fileMenu = new JMenu("File"); 47 | fileMenu.setMnemonic('F'); 48 | 49 | JMenuItem exit = new JMenuItem("Exit"); 50 | exit.setMnemonic('x'); 51 | exit.addActionListener(new ActionListener() { 52 | @Override 53 | public void actionPerformed(ActionEvent e) { 54 | System.exit(0); 55 | } 56 | }); 57 | 58 | fileMenu.add(exit); 59 | return fileMenu; 60 | } 61 | 62 | /** 63 | * Creates the help menu. 64 | *

65 | * The help menu contains an "About" item, to display some software information. 66 | *

67 | * 68 | * @return the newly created help menu. 69 | */ 70 | private JMenu createHelpMenu() { 71 | JMenu helpMenu = new JMenu("Help"); 72 | helpMenu.setMnemonic('h'); 73 | 74 | JMenuItem about = new JMenuItem("About"); 75 | about.setMnemonic('a'); 76 | about.addActionListener(new ActionListener() { 77 | @Override 78 | public void actionPerformed(ActionEvent e) { 79 | JOptionPane.showMessageDialog(menuBar.getParent(), 80 | String.format("Extremely simple Markdown to HTML converter%nPowered by MarkdownJ%nhttps://github.com/nilhcem"), 81 | "Markdown2HTML: About", JOptionPane.INFORMATION_MESSAGE); 82 | } 83 | }); 84 | 85 | helpMenu.add(about); 86 | return helpMenu; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/nilhcem/md2html/gui/PreviewPane.java: -------------------------------------------------------------------------------- 1 | package com.nilhcem.md2html.gui; 2 | 3 | import java.util.Observable; 4 | import java.util.Observer; 5 | import javax.swing.JLabel; 6 | import javax.swing.JScrollPane; 7 | import javax.swing.SwingUtilities; 8 | import com.petebevin.markdown.MarkdownProcessor; 9 | 10 | /** 11 | * Scrolled text area where will be displayed the HTML preview. 12 | * 13 | * @author Nilhcem 14 | * @since 1.0 15 | */ 16 | public final class PreviewPane implements Observer { 17 | private final JScrollPane previewPane = new JScrollPane(); 18 | private final JLabel previewLabel = new JLabel(); 19 | 20 | /** 21 | * Creates the HTML JLabel and sets its vertical alignment as in the top. 22 | */ 23 | public PreviewPane() { 24 | previewLabel.setVerticalAlignment(JLabel.TOP); 25 | previewPane.getViewport().add(previewLabel, null); 26 | } 27 | 28 | /** 29 | * Returns the JScrollPane object. 30 | * 31 | * @return the JScrollPane object. 32 | */ 33 | public JScrollPane get() { 34 | return previewPane; 35 | } 36 | 37 | /** 38 | * Updates the content of the label by converting the input data to html and setting them to the label. 39 | *

40 | * This method will be called by an {@code InputPane} observable. 41 | *

42 | * 43 | * @param o the observable element which will notify this class. 44 | * @param data a String object containing the input data to be converted into HTML. 45 | */ 46 | @Override 47 | public void update(final Observable o, final Object data) { 48 | if (o instanceof InputPane) { 49 | SwingUtilities.invokeLater(new Runnable() { 50 | @Override 51 | public void run() { 52 | String content = (String)data; 53 | MarkdownProcessor processor = new MarkdownProcessor(); 54 | previewLabel.setText(String.format("%s", processor.markdown(content)).replaceAll("src=\"", "src=\"file:")); // Fix to display images properly. 55 | } 56 | }); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/nilhcem/md2html/gui/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes used while running the program in a GUI. 3 | */ 4 | package com.nilhcem.md2html.gui; 5 | -------------------------------------------------------------------------------- /src/main/java/com/nilhcem/md2html/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Entry point of the application. 3 | */ 4 | package com.nilhcem.md2html; 5 | --------------------------------------------------------------------------------