markdown-up

1.9.1 • Public • Published

MarkdownUp

npm GitHub

MarkdownUp is a Markdown viewer.

Links

View Local Markdown Files

To view local Markdown files, use the MarkdownUp launcher from a terminal prompt:

pip install markdown-up
markdown-up

Host Markdown Web Pages

To host a Markdown resource, download the MarkdownUp application stub to the directory containing your Markdown files:

curl -O https://craigahobbs.github.io/markdown-up/extra/index.html

To test your Markdown page, start a local static web server:

python3 -m http.server

By default, MarkdownUp fetches the "README.md" resource. To change the default resource, update the application stub file, index.html. For example:

    ...
    <script type="module">
        import {MarkdownUp} from 'https://craigahobbs.github.io/markdown-up/lib/app.js';
        const app = new MarkdownUp(window, {'url': 'other.md'});
        app.run();
    </script>
    ...

To view a different Markdown resource, set the application's "url" hash parameter (i.e., "http://127.0.0.1:8000#url=other.md").

Dynamic Markdown Applications

Using MarkdownUp's "markdown-script" fenced code blocks, you can dynamically generate Markdown, allowing you to build lightweight, client-rendered web applications with no HTML, no CSS, and a single dependency (MarkdownUp). The "markdown-script" fenced code blocks are interpreted as the CalcScript programming language. In addition to generating Markdown, you can fetch text and JSON resources, create SVG drawings, parse CSV, render data tables, draw line charts, and more. For more information, see the MarkdownUp Library.

For example:

# Dynamic Markdown Example

~~~ markdown-script
# Variable arguments
helloCount = if(vCount != null, vCount, 3)

# Constants
width = 200
height = 60
borderSize = 5

# Render the more/less menu
markdownPrint( \
    '', \
    if(helloCount <= 1, 'Less', '[Less](#var.vCount=' + (helloCount - 1) + ')') + ' | ', \
    '[More](#var.vCount=' + (helloCount + 1) + ')' \
)

# Render many hellos
ixHello = 0
while ixHello < helloCount do
    # Render the hello title
    helloTitle = 'Hello #' + (ixHello + 1)
    markdownPrint('', '## ' + helloTitle)

    # Render the hello drawing
    setDrawingSize(width, height)
    drawStyle('red', borderSize, 'blue')
    drawRect(0.5 * borderSize, 0.5 * borderSize, width - borderSize, height - borderSize)
    drawTextStyle(0.67 * height, 'white', true)
    drawText(helloTitle, 0.5 * width, 0.55 * height)

    ixHello = ixHello + 1
endwhile
~~~

Click here to see the example in action.

The MarkdownUp Include Library

MarkdownUp provides some additional functionality that can be included at runtime. Consider the following example with the unit test include library:

include 'https://craigahobbs.github.io/markdown-up/include/unittest.mds'

function testSanity()
    unittestEquals(1 + 1, 2)
endfunction
unittestRunTest('testSanity')

unittestReport()

See the MarkdownUp Include Library documentation for more information on the available include libraries.

Debug Mode

Debug mode enables logging output using the debugLog function. For example:

debugLog('Hello debug')

Debug mode also enables the CalcScript linter, which performs static code analysis on your code and reports warnings for any issues found.

To turn on debug mode, click the debug button in the MarkdownUp menu in the upper-right of the page.

Links

The MarkdownUp Package

The markdown-up package contains functions for parsing CSV, manipulating data, and rendering tables and charts. For more information, refer to the MarkdownUp package documentation.

Development

This package is developed using javascript-build. It was started using javascript-template as follows:

template-specialize javascript-template/template/ markdown-up/ -k package markdown-up -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs'

Install

npm i markdown-up

DownloadsWeekly Downloads

5

Version

1.9.1

License

MIT

Unpacked Size

126 kB

Total Files

9

Last publish

Collaborators

  • craigahobbs