Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kjdev/hoextdown

Hoextdown is an extension to Hoedown
https://github.com/kjdev/hoextdown

Last synced: 25 days ago
JSON representation

Hoextdown is an extension to Hoedown

Awesome Lists containing this project

README

        

# Hoextdown

[![Build Status](https://api.travis-ci.org/kjdev/hoextdown.png?branch=master)](https://travis-ci.org/kjdev/hoextdown)
[![codecov.io](https://codecov.io/github/kjdev/hoextdown/coverage.svg?branch=master)](https://codecov.io/github/kjdev/hoextdown?branch=master)
![CodeQL](https://github.com/kjdev/hoextdown/workflows/CodeQL/badge.svg?branch=master)

`Hoextdown` is an extension to [Hoedown](https://github.com/hoedown/hoedown).

Extended the following functions.

* [Special Attributes](#special-attributes)
* [Task Lists](#task-lists)
* [Line Continue](#line-continue)
* [Header ID](#header-id)
* [Fenced Script](#fenced-script)
* [Script Tags](#script-tags)
* [Meta Block](#meta-block)
* [Definition Lists](#definition-lists)

## Special Attributes

Add the `HOEDOWN_EXT_SPECIAL_ATTRIBUTE` to Hoedown document flags.

Set the id and class attribute on certain elements using an attribute block.

For instance, put the desired id prefixed by a hash inside curly brackets after
the header at the end of the line, like this

```
Header 1 {#header1}
========

## Header 2 ## {#header2}
```

Then you can create links to different parts of the same document like this:

```
[Link back to header 1](#header1)
```

To add a class name, which can be used as a hook for a style sheet, use a dot
like this:

```
## The Site ## {.main}
```

The id and multiple class names can be combined by putting them all into the
same special attribute block:

```
## The Site ## {.main .shine #the-site}
```

To add a other than id and class names, use a colon like this:

```
## The Site ## {.main .shine #the-site :color=red}
```

At this time, special attribute blocks can be used with

* headers
* fenced code blocks
* links
* images
* tables
* paragraphs

For image and links, put the special attribute block immediately after the
parenthesis containing the address:

```
[link](url){#id .class}
![img](url){#id .class}
```

Or if using reference-style links and images, put it at the end of the
definition line like this:

```
[link][linkref] or [linkref]
![img][linkref]

[linkref]: url "optional title" {#id .class}
```

For paragraphs, put the special identifier `@paragraph` after the attribute.
This helps prevent accidental parsing.

```
This is a paragraph. {@paragraph #id}
```

## Task Lists

Add the `HOEDOWN_HTML_USE_TASK_LIST` to Hoedown html flags.

Add to support task lists, Task lists are lists with items marked as either [ ]
or [x] (incomplete or complete), like this

```
- [ ] a task list item
- [ ] list syntax required
- [ ] normal **formatting**, @mentions, #1234 refs
- [ ] incomplete
- [x] completed
```

## Line Continue

Add the `HOEDOWN_HTML_LINE_CONTINUE` to Hoedown html flags.

Remove the line breaks at the end of the line.

## Header ID

Add the `HOEDOWN_HTML_HEADER_ID` to Hoedown html flags.

Output header id.

```
# Header 1
```

becomes:

```

Header 1


```

## Fenced Script

Add the `HOEDOWN_HTML_FENCED_CODE_SCRIPT` to Hoedown html flags.
(`HOEDOWN_EXT_FENCED_CODE` also need to be specified at the same time)

Output the script tag in the fenced code style.

``` script@text/javascript
alert("Example");
```

becomes:

```

alert("Example");

```

## Script Tags

Add the `HOEDOWN_EXT_SCRIPT_TAGS` to Hoedown document flags.

Add the parsing process of script tags `..?>`.

```
This is test.

```

becomes:

```

This is test.

```

## Meta Block

Add the `HOEDOWN_EXT_META_BLOCK` to Hoedown document flags.

Add the parsing process of meta block ``.

Get a meta block by running in the following program.

```c
/*
Allocate meta block buffer
*/
hoedown_buffer *meta;
meta = hoedown_buffer_new(64);

/*
Set HOEDOWN_EXT_META_BLOCK to hoedown_extensions.
Specifies the meta block buffer to fifth argument.
*/
document = hoedown_document_new(renderer, HOEDOWN_EXT_META_BLOCK, 6, NULL, meta);

/*
Print meta block buffer
*/
if (meta->size > 0) {
fprintf(stdout, "-- Meta Block --\n");
(void)fwrite(meta->data, 1, meta->size, stdout);
}

hoedown_buffer_free(meta);
```

Execution parse result.

```

This is hoextdown example.
```

becomes:

```

This is hoextdown example.


--- Meta Block --
author: user
title: Readme markdown parser
```

## Definition Lists

Add the `HOEXTDOWN_EXT_DEFINITION_LISTS` to Hoedown document flags.

Add to support definition lists. Syntax follows [PHP Markdown Extra's syntax](https://michelf.ca/projects/php-markdown/extra/#def-list).

```
Term
: Definition

Term 1
Term 2
: Definition 2

Term 3
: Definition Line 1
Definition Line 2

Extra paragraphs need four spaces.
```

becomes:

```


Term

Definition

Term 1

Term 2

Definition 2

Term 3


Definition Line 1 Definition Line 2


Extra paragraphs need four spaces.




```