Skip to content

joshnatis/phd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 

Repository files navigation

phd

A Markdown to HTML compiler

euripides

No need for Medical Doctors when you have a Doctor of Philosophy on hand - Gangsta Euripides

NOTE

This tool is currently a Markdown to HTML converter and part of a static blog generator stuffed in one vehicle. I have been meaning to fix this for a long time but haven't gotten around to it just yet. Here are some TODOs:

  • write a (E)BNF grammar for the language I’m implementing (rather than an informal listing of features)
  • decouple the blog functionality from the Markdown parsing functionality
    • corollary: allow Markdown parsing portion to be used as a header library
  • better error checking
  • tests (pass at least most of John Gruber's Markdown tests)
  • use less ad-hoc parsing techniques
  • become a UNIX filter program (accept from stdin, write to stdout)

Install

  • git clone https://github.com/joshnatis/phd
  • edit the variables in the config() function on top of phd.cpp to configure your settings
  • make
  • Optional: install highlight.js from their page for syntax highlighting in code blocks. If you choose not to install it, make sure to set the USING_HIGHLIGHT_JS flag to false in phd.cpp.

Usage

  • ./phd input.md output.html

Dependencies

c++11 and make

Current features

  • Headings
    • #, ##, ###, ... ######
    • <h1> through <h6>
  • Emphasis
    • **x** or __x__ for bold
    • *x* or _x_ for italic
    • ~~x~~ for strikethrough
    • ==x== for highlight
    • ++x++ for underline
    • ^x^ for superscript
    • ~x~ for subscript
  • Code blocks
    • ```[optional language] <newline> ... <newline> ```
    • automatic syntax highlighting if you link the highlight.js script
  • Inline code
    • `This is inline code`
    • This surrounds the inline code in <code> tags with the class inline-code. You can add styles for .inline-code to change how it looks.
  • Images
    • ![alt](url)
    • ![alt](url)|inline css, e.g. width: 50%; height: 30%|
  • Links
    • [link text](https://url.com)
  • <hr> (horizontal rule)
    • ---
  • Line breaks
    • One or more blank lines between content in the markdown will yield a blank line in the resultant html
    • You can freely use <br> tags
  • Blockquotes
    • > this is all a blockquote
    • Consecutive >'s with no blank lines between will all be funneled into a single blockquote
  • Lists
    • * , + , or - for bulleted lists, 1. (or any number) for numbered lists
    • To nest lists, include two spaces or a tab before your bullet point
  • Escaped characters
    • \>, \&, \<, \*, \_, \^, \~, \`

Missing features (for now)

  • Alternate URL syntax
    • [https://url.com], <url.com>, and/or https://url.com.
  • Nesting different types of lists together is buggy
  • Nesting lists in general is buggy because I misunderstood how nesting lists in HTML works
  • Inline code gets parsed for tags (it should have no formatting)
  • <a> tags get parsed for tags (vry bad, this ruins links)

Missing features (forever)

  • Everything else (wait... there's not much else)

Note From the Author

I didn't use regex, so now I only have 99 problems instead of 2.

Pictures!

I know you want em...

Markdown


HTML


An example blog lives here.

About

A Markdown to HTML compiler, great for blog posts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published