Parse_mode Markdown



  • Initialization (INI) configuration parser
  • Dynamic Syntax parser

The Bot API is an HTTP-based interface created for developers keen on building bots for Telegram.To learn how to create. How to format your text with Markdown. You can parse Markdown in our tables to format the text in not just rows and columns, but individual cells. If your data contains Markdown or if you added it in step 2: Check & Describe, make your formatting visible with checking 'parse Markdown.

Introduction

  • Parse-mode Set to Markdown or HTML for Markdown-formatted or HTML-formatted alert messages. The default parse-mode is Markdown.
  • Markdown, LaTeX, Emacs Org mode, ConTeXt. For output formats other than LaTeX, pandoc will parse LaTeX newcommand and renewcommand definitions.

October uses several standards for processing markup, templates and configuration. Each has been carefully selected to serve their role in making your development process and learning curve as simple as possible. As an example, the objects found in a theme use the Twig and INI format in their template structure. Each parser is described in more detail below.

Markdown parser

Markdown allows you to write easy-to-read and easy-to-write plain text format, which then converts to HTML. The Markdown facade is used for parsing Markdown syntax and is based on GitHub flavored markdown. Some quick examples of markdown:

Markdown

Use the Markdown::parse method to render Markdown to HTML:

You may also use the |md filter for parsing Markdown in your front-end markup.

Twig template parser

Twig is a simple but powerful template engine that parses HTML templates in to optimized PHP code, it the driving force behind the front-end markup, view content and mail message content.

The Twig facade is used for parsing Twig syntax, you may use the Twig::parse method to render Twig to HTML.

The second argument can be used for passing variables to the Twig markup.

The Twig parser can be extended to register custom features via the plugin registration file.

Bracket parser

October also ships with a simple bracket template parser as an alternative to the Twig parser, currently used for passing variables to theme content blocks. This engine is faster to render HTML and is designed to be more suitable for non-technical users. There is no facade for this parser so the fully qualified OctoberRainParseBracket class should be used with the parse method.

The syntax uses singular curly brackets for rendering variables:

You may also pass an array of objects to parse as a variable.

The array can be iterated using the following syntax:

YAML configuration parser

YAML ('YAML Ain't Markup Language') is a configuration format, similar to Markdown it was designed to be an easy-to-read and easy-to-write format that converts to a PHP array. It is used practically everywhere for the back-end development of October, such as form field and list column definitions. An example of some YAML:

The Yaml facade is used for parsing YAML and you use the Yaml::parse method to render YAML to a PHP array:

Use the parseFile method to parse the contents of a file:

The parser also supports operation in reverse, outputting YAML format from a PHP array. You may use the render method for this:

Initialization (INI) configuration parser

The INI file format is a standard for defining simple configuration files, commonly used by components inside theme templates. It could be considered a cousin of the YAML format, although unlike YAML, it is incredibly simple, less sensitive to typos and does not rely on indentation. It supports basic key-value pairs with sections, for example:

The Ini facade is used for parsing INI and you use the Ini::parse method to render INI to a PHP array:

Use the parseFile method to parse the contents of a file:

The parser also supports operation in reverse, outputting INI format from a PHP array. You may use the render method for this:

October flavored INI

Traditionally, the INI parser used by the PHP function parse_ini_string is restricted to arrays that are 3 levels deep. For example:

October has extended this functionality with October flavored INI to allow arrays of infinite depth, inspired by the syntax of HTML forms. Following on from the above example, the following syntax is supported:

Dynamic Syntax parser

Dynamic Syntax is a templating engine unique to October that fundamentally supports two modes of rendering. Parsing a template will produce two results, either a view or editor mode. Take this template text as an example, the inner part of the {text}...{/text} tags represents the default text for the view mode, while the inner attributes, name and label, are used as properties for the editor mode.

Python Parse Markdown

There is no facade for this parser so the fully qualified OctoberRainParseSyntaxParser class should be used with the parse method. The first argument of the parse method takes the template content as a string and returns a Parser object.

View mode

Let's say we used the first example above as the template content, calling the render method by itself will render the template with the default text:

Just like any templating engine, passing an array of variables to the first argument of render will replace the variables inside the template. Here the default value of websiteName is replaced with our new value:

As a bonus feature, calling the toTwig method will output the template in a prepared state for rendering by the Twig engine.

Editor mode

So far the Dynamic Syntax parser is not much different to a regular template engine, however the editor mode is where the utility of Dynamic Syntax becomes more apparent. The editor mode unlocks a new realm of possibility, for example, where layouts inject custom form fields to pages that belong to them or for dynamically built forms used in email campaigns.

To continue with the examples above, calling the toEditor method on the Parser object will return a PHP array of properties that define how the variable should be populated, by a form builder for example.

You may notice the properties closely resemble the options found in form field definintions. This is intentional so the two features compliment each other. We could now easily convert the array above to YAML and write to a fields.yaml file:

Supported tags

There are various tag types that can be used with the Dynamic Syntax parser, these are designed to match common form field types.

Text

Single line input for smaller blocks of text.

Textarea

Multiple line input for larger blocks of text.

Dropdown

Renders a dropdown form field.

Radio

Renders a radio form field.

Variable

Renders the form field type exactly as defined in the type attribute. This tag will simply set a variable and will render in view mode as an empty string.

Parse Markdown Powershell

Rich editor

Text input for rich content (WYSIWYG).

Renders in Twig as

Markdown

Parse_mode=telegram.parse_mode.markdown

Text input for Markdown content.

Renders in Twig as

Media finder

File selector for media library items. This tag value will contain the relative path to the file.

Renders in Twig as

Parse_mode Markdown

File upload

File uploader input for files. This tag value will contain the full path to the file.

Repeater

Renders a repeating section with other fields inside.

Renders in Twig as

Calling $syntax->toEditor will return a different array for a repeater field:

Please enable JavaScript to view the comments powered by Disqus.

Write and Parse Markdown into HTML + CSS on the fly!

un-encrypted 100% Xojo code class with access to the source code, gives Xojo developers the ability to write and parse Markdown to HTML + CSS instantly! Use the markdown text as the source for the class instance and get on the fly the HTML with the CSS styles provided as result, so you get the visually enriched HTML ready to use as is or for additional purposes in your project thanks to the flexibility provided by HTML!

  • Six levels of headers
  • Links
  • Images
  • Tables
  • Lists
  • Code inline and Blocks of code
  • Bold, Italic, Striketrough text styles
  • Quotes
  • Separator

Markdown parser for Xojo is compatible with 32 and 64 bits deployments for Console, Desktop, Web, RaspberryPi, MacOS, Windows and Linux!