Giter Club home page Giter Club logo

term-rst-post's Introduction

Term RST Post

Convert documents in reStructuredText (RST) to text files suitable to be displayed in a terminal shell. The text files are formatted using a mixture of ANSI escape codes and markdown. It is also possible to wrap the resulting text to an arbitrary column width.

Features

rst2ansi

Convert RST documents to text files formatted with markdown and ANSI escape codes

  • Custom docutils translator to text files with ANSI escape codes
  • Wrapper of text files that is aware of escape characters (--wrap)
  • Supported RST elements:
    • title: markdown title plus ANSI bold text
    • subtitle: markdown title
    • section: markdown paragraphs
    • strong: ANSI bold text
    • emphasis: ANSI underline text
    • literal: markdown literal plus ANSI inverse text
    • reference: print link labels and URLs
    • bullet list: markdown unordered list
    • enumerated list: markdown unordered list
  • Support for custom substitutions:
    • |Warning|: ANSI red background
    • |Info|: ANSI green background
    • other substitutions will be converted to plain text
  • Support for extra directives:

news2motd

Parse posts from ABlog and convert them to a text file to be used as message of the day (MOTD).

  • Same conversion features of RST documents as rst2ansi
  • Convert any RST file with a post from ABlog to text format using ANSI escape codes
  • Optionally, parse an HTML file with a feed of posts from ABlog and retrieve the most recent post RST document
  • Use the publication date of the post to determine if the post is worth being published as MOTD (--lifespan)
  • Generate brief MOTD with a single paragraph from RST document (--briefing)
  • Add additional header or footer sections to the MOTD (--motd-header, --motd-footer)
  • Add additional link in the MOTD to the HTML page of the post (--ablog-url)

Requirements

  • Python >=3.6
  • ablog >=0.10.0
  • sphinx
  • docutils
  • beautifulsoup4
  • (tests) pytest

Example

The following command will convert the example RST file with all supported elements into a text file with ANSI escape codes (display the text file in your terminal).

$ rst2ansi tests/examples/ablog_newspost_complete.rst

The following example generates a MOTD considering the given HTML news feed of ABlog. New MOTD will be stored in the default file called news.motd. Any news item converted to MOTD will have an additional header, footer and link. In this case the root directory with RST files will be automatically determined from the news feed HTML file.

$ news2motd _website/posts/tag/motd/index.html
  --briefing
  --motd-header motd/_templates/motd-head.ansi
  --motd-footer motd/_templates/motd-foot.ansi
  --ablog-url http://example.com/

term-rst-post's People

Contributors

jantur3k avatar lexming avatar smoors avatar wpoely86 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.