npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

roku-markdown

v0.2.2

Published

Markdown parser/renderer for Roku apps

Downloads

1

Readme

Roku markdown renderer

This is a simple markdown renderer for Roku apps written in BrighterScript.

Screenshot of the markdown demo app

Parser and renderer support a subset of the markdown spec, and strip all inline styles. The goal is to eventually support images between paragraphs.

There is currently no plan to support full text styling, but might consider tables.

Current support:

  • titles, using # Title syntax
  • paragraphs
  • code blocks, using triple-tick or indentation
  • quote blocks, using > That quote
  • horizontal rules, using 3+ characters of -=*

Installation

Using ropm

ropm install roku-markdown

Suggestion: use a shorter prefix:

ropm install md@npm:roku-markdown

Usage

See demo.bs in the repository sources for an example of usage.

Following example use unprefixed installation. Replace rokumarkdown_ with md_ if you used the prefix as suggested.

1. Declare a renderer view

<rokumarkdown_Renderer id="markdownView" />

You can redefine some/all the fonts and colors/alignments:

<rokumarkdown_Renderer id="markdownView" color="#FFFFCC" h1Align="center">
    <Font role="font" uri="pkg:/fonts/Ubuntu_Regular.ttf" size="24" />
    <Font role="h1Font" uri="pkg:/fonts/Ubuntu_Bold.ttf" size="48" />
    <Font role="h2Font" uri="pkg:/fonts/Ubuntu_Bold.ttf" size="36" />
</rokumarkdown_Renderer>

Full interface:

<interface>
    <field id="width" type="int" />
    <field id="height" type="int" />
    <field id="padding" type="array" />
    <field id="itemSpacing" type="int" />
    <field id="font" type="node" />
    <field id="color" type="string" />
    <field id="align" type="string" />
    <field id="quoteFont" type="node" />
    <field id="quoteColor" type="string" />
    <field id="quoteAlign" type="string" />
    <field id="quotePadding" type="array" />
    <field id="quoteBackground" type="string" />
    <field id="codeFont" type="node" />
    <field id="codeColor" type="string" />
    <field id="codeAlign" type="string" />
    <field id="codePadding" type="array" />
    <field id="codeBackground" type="string" />
    <field id="h1Font" type="node" />
    <field id="h1Color" type="string" />
    <field id="h1Align" type="string" />
    <field id="h2Font" type="node" />
    <field id="h2Color" type="string" />
    <field id="h2Align" type="string" />
    <field id="h3Font" type="node" />
    <field id="h3Color" type="string" />
    <field id="h3Align" type="string" />
    <field id="h4Font" type="node" />
    <field id="h4Color" type="string" />
    <field id="h4Align" type="string" />
    <field id="hrColor" type="string" />
    <field id="hrSize" type="int" />
    <field id="animatedScrolling" type="boolean" alias="scroller.animatedScrolling" />
    <field id="scrollFraction" type="integer" alias="scroller.scrollFraction" />
    <field id="scrollRatio" type="integer" alias="scroller.scrollRatio" />
    <field id="overflows" type="boolean" />
    <function name="render" />
</interface>

Paddings are arrays of numbers following CSS rules:

  • [all]
  • [top-bottom, right-left]
  • [top, right, bottom, left]

Colors are Roku RRGGBB or RRGGBBAA color string, e.g. "#FFFFFF33"

Backgrounds are:

  • either Roku RRGGBB or RRGGBBAA color string, e.g. "#FFFFFF33",
  • or a custom Roku component; the size is provided through size field ([width, height]), and the text label is appended as a child (see demo).

Alignments are Label horizontal alignement values (left|center|right)

Titles after H4 are all rendered as H4.

2. Parse markdown source and render

Vanilla BrightScript version

parser = rokumarkdown_Parser()
data = parser.parse(markdownSrc)

view = m.top.findNode("markdownView")
view.callfunc("render", data)

' view is scrollable and can be focused
view.setFocus(true)

If you want an optimised non-interactive clipped render:

view.callfunc("render", data, false)
' view isn't scrollable anymore

BrighterScript version

parser = new rokumarkdown_Parser()
data = parser.parse(markdownSrc)

view = m.top.findNode("markdownView")
[email protected](data)

' view is scrollable and can be focused
view.setFocus(true)

If you want an optimised non-interactive clipped render:

[email protected](data, false)
' view isn't scrollable anymore

3. Render scrolling decorations

This component will not render a scrollbar:

  • overflows tells whether the content is bigger than the view,
  • you can observe scrollFraction to know the state of the scrolling,
  • you can use scrollRatio to know how much of the content is visible VS hidden.

See the repository demo for an example rendering a scrollbar.

Building from source

  1. Install NodeJS
  2. install npm dependencies
    npm install
  3. Transpile to vanilla brightscript (under /dist)
    npm run build

Debugging

This repository comes pre-configured to work with the BrightScript Language extension for Visual Studio Code. So once you have that plugin installed, debugging your project is as simple as clicking the "Start Debugging" button.