{"id":23722801,"url":"https://github.com/fulminazzo/markdownparser","last_synced_at":"2026-05-08T00:36:45.721Z","repository":{"id":213738383,"uuid":"730332484","full_name":"Fulminazzo/MarkdownParser","owner":"Fulminazzo","description":"A simple Markdown parser. It provides an API to work with Markdown elements.","archived":false,"fork":false,"pushed_at":"2024-01-24T02:21:54.000Z","size":163,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-30T23:56:47.053Z","etag":null,"topics":["github-actions","java","markdown","parser"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fulminazzo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-11T17:36:11.000Z","updated_at":"2023-12-24T20:53:38.000Z","dependencies_parsed_at":"2023-12-22T18:36:58.336Z","dependency_job_id":"e45f569a-5e2e-49e0-b4f5-d0d19404ac27","html_url":"https://github.com/Fulminazzo/MarkdownParser","commit_stats":null,"previous_names":["fulminazzo/markdownparser"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fulminazzo%2FMarkdownParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fulminazzo%2FMarkdownParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fulminazzo%2FMarkdownParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fulminazzo%2FMarkdownParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fulminazzo","download_url":"https://codeload.github.com/Fulminazzo/MarkdownParser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239818230,"owners_count":19702091,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-actions","java","markdown","parser"],"created_at":"2024-12-30T23:56:53.617Z","updated_at":"2026-05-08T00:36:40.685Z","avatar_url":"https://github.com/Fulminazzo.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MarkdownParser\nAs the name implies, this project is a **Java Markdown parser**.\nIt provides an [Object Oriented API](#nodes) which allows to **work** with and **manipulate Markdown elements**,\nas well as a simple command interface to test and work with files.\n\nHere are the main commands:\n- `read \u003cfile\u003e`: reads and parses the specified file, showing the output in terminal;\n- `copy \u003cfile1\u003e \u003cfile2\u003e`: reads and parses file `file1` and writes the output to `file2`;\n- `optimize \u003cfile\u003e`: optimizes the specified file by reading, parsing and removing unnecessary spaces, new lines or quotes;\n- `separate \u003cfile\u003e`: searches for **headers** in the specified file after parsing it.\n  If any is found, the lower ones will be saved in different files, and the main file is overwritten.\n  Say you have `main.md` file containing:\n  ```markdown\n  Are you ready to learn the power of MarkdownParser?\n  \n  # Sure\n  I am excited!\n  \n  # No\n  I still need more time...\n  ```\n  Then, three files will be created:\n  - `Sure.md`, with contents `I am excited!`;\n  - `No.md`, with contents `I still need more time...`;\n  - `main.md`, will be overwritten with contents `Are you ready to learn the power of MarkdownParser?`.\n\n## How does it work\n**MarkdownParser** takes as input a **string** (or **raw data**, check out [RootNode](#rootnode) for more)\nand returns a **group of nodes** representing each found element.\nIt uses **regular expressions** to search and individuate valid Markdown items\nand **converting** them into a similar HTML **tag format**.\n\nFor example, say the given input is:\n```markdown\n# Hello world\nThis project is great!\n```\nThe `HEADER1` regular expression will convert it into its tagged form:\n```html\n\u003cHEADER1\u003eIyBIZWxsbyB3b3JsZApUaGlzIHByb2plY3QgaXMgZ3JlYXQh\u003c/HEADER1\u003e\n```\nWhere the content of the tags is the **Base64 encoded version of the Markdown form**.\nIt will later be used by other nodes that will **decode it** and **repeat this process**, \nuntil a simple text is met (in which case, it will be used a [SimpleTextNode](#simpletextnode)).\n\n# API\nTo start using the API, you can import **MarkdownParser** either from Maven or Gradle:\n- **Maven**:\n```xml\n\u003crepositories\u003e\n  \u003crepository\u003e\n    \u003cid\u003efulminazzo-repository\u003c/id\u003e\n    \u003curl\u003ehttps://repo.fulminazzo.it/releases\u003c/url\u003e\n  \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n```xml\n\u003cdependencies\u003e\n  \u003cdependency\u003e\n    \u003cgroupId\u003eit.fulminazzo\u003c/groupId\u003e\n    \u003cartifactId\u003eMarkdownParser\u003c/artifactId\u003e\n    \u003cversion\u003e1.0\u003c/version\u003e\n  \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n- **Gradle**:\n```groovy\nrepositories {\n    maven { url = \"https://repo.fulminazzo.it/releases\" }\n}\n\ndependencies {\n  implementation 'it.fulminazzo.MarkdownParser:1.0'\n}\n```\n\n## Nodes\nTo read and translate **Markdown** data into **MarkdownParser API**, many nodes are provided. \n\nWhen starting to read data, you should always start with [RootNode](#rootnode).\n\n| Nodes                             |\n|-----------------------------------|\n| [Node](#node)                     |\n| [RootNode](#rootnode)             |\n| [SimpleTextNode](#simpletextnode) | \n| [TextNode](#textnode)             |\n| [LinkNode](#linknode)             |\n| [TextBlock](#textblock)           |\n| [HeaderNode](#headernode)         |\n| [ListNode](#listnode)             |\n| [CodeNode](#codenode)             |\n| [CommentNode](#commentnode)       |\n| [QuoteNode](#quotenode)           |\n| [TableNode](#tablenode)           |\n\n### Node\n[Node](/src/main/java/it/fulminazzo/markdownparser/nodes/Node.java) \nis the **basic implementation** for every node of the program.\nA node is simply an object that might contain some **content**\n(in which case, it can be set with the `setContent(String)` method),\nand has:\n- a **parent** that can be retrieved with `getParent()`;\n- **siblings**, that can be retrieved with `getPrev()` and `getNext()`;\n- a **child** (with its siblings),\n  that can be retrieved\n  with `getChild()` or with `getChildren()` to get a full [NodesList](/src/main/java/it/fulminazzo/markdownparser/objects/NodesList.java).\n\nBasically, a node works pretty much like a [Tree data structure](https://en.wikipedia.org/wiki/Tree_(data_structure)).\n\nIt also provides some useful functions to work with:\n- `serialize()`: **converts the current node** into its corresponding **Markdown format**;\n- `serializeChildren()`: calls `serialize()` for every **child**. Usually, this gets called in `serialize()` by default;\n- `toString()`: prints the **node name** and its [ContentMap](/src/main/java/it/fulminazzo/markdownparser/objects/ContentMap.java);\n- `write(File)` and `write(OutputStream)`: respectively call the `serialize()` method and **write the result** on the given **file** or **stream**.\n\n### RootNode\n[RootNode](/src/main/java/it/fulminazzo/markdownparser/nodes/RootNode.java) \nis the main starting point for **reading** any **Markdown data**.\nIt is just a **wrapper** that contains the read data from one of its constructors:\n```java\npublic RootNode(File file) throws IOException;\n\npublic RootNode(InputStream inputStream) throws IOException;\n\npublic RootNode(String rawContent);\n```\n\n### SimpleTextNode\n[SimpleTextNode](/src/main/java/it/fulminazzo/markdownparser/nodes/SimpleTextNode.java)\nrepresents a **simple text** in Markdown with **no formatting**.\nFor example, in:\n```markdown\n# Hello world\nThis project is great!\n```\n`This project is great!` will be saved in a **SimpleTextNode**, since it has nothing special to it.\n\nHowever, say it was:\n```markdown\n# Hello world\nThis project is **great!**\n```\nIn this case, there would be two **SimpleTextNodes**: `This project is ` and `great!`,\nthat will be encapsulated in a [TextNode](#textnode).\n\n### TextNode\n[TextNode](/src/main/java/it/fulminazzo/markdownparser/nodes/TextNode.java)\nrepresents a **text** that **supports formatting**.\nCheckout [TextType](/src/main/java/it/fulminazzo/markdownparser/enums/TextType.java)\nto understand which formats are available.\n\nSay you have:\n```markdown\n# Hello world\nThis project is **great!**\n```\nThen, `**great!**`\nwill be saved as a **TextNode** of type [Strong](/src/main/java/it/fulminazzo/markdownparser/enums/TextType.java)\nand its content (`great!`) will become its child in the form of [SimpleTextNode](#simpletextnode):\n```\nTextNode: {\n    text-type: STRONG,\n    children: {\n        SimpleTextNode: great!\n    }\n}\n```\n\n### LinkNode\n[LinkNode](/src/main/java/it/fulminazzo/markdownparser/nodes/LinkNode.java)\nrepresents a **simple link**.\nIt supports **hover text**, meaning that both these formats will be valid:\n```markdown\n[Good Java Project](https://github.com/Fulminazzo/MarkdownParser)\n[Good Java Project](https://github.com/Fulminazzo/MarkdownParser \"This project is great!\")\n```\n\n### TextBlock\nA [TextBlock](/src/main/java/it/fulminazzo/markdownparser/nodes/TextBlock.java)\nis just a **wrapper** node for text blocks.\nA **text block is** considered as such when it is **separated** by a **pair of new lines** (`\\n\\n`).\n\nIt has no special method for editing its contents, apart from the ones already discussed in the [Node section](#node).\n\n### HeaderNode\n[HeaderNode](/src/main/java/it/fulminazzo/markdownparser/nodes/HeaderNode.java)\nrepresents a **header** with its contents.\nA **content of a header** is decided when a header of **same length** is met or the **end of file** is reached.\n\nSo, for example:\n```markdown\n# Hello World\nThis project is great!\n```\nWill be loaded as:\n```\nHeaderNode: {\n    header-size: 1,\n    header: Hello World,\n    children: {\n        TextBlock: {\n            children: {\n                TextNode: {\n                    children: {\n                        SimpleTextNode: This project is great!\n                    }\n                }\n            }\n        }\n    }\n}\n```\nBut say you had:\n```markdown\n# Hello World\nThis project is great!\n\n# Another paragraph\nDon't you agree?\n```\nIn this case, since the **two headers** are of the same size, they will be loaded as **siblings**:\n```\nHeaderNode: {\n    header-size: 1,\n    header: Hello World,\n    children: {\n        TextBlock: {\n            children: {\n                TextNode: {\n                    children: {\n                        SimpleTextNode: This project is great!\n                    }\n                }\n            }\n        }\n    }\n},\nHeaderNode: {\n    header-size: 1,\n    header: Another paragraph,\n    children: {\n        TextBlock: {\n            children: {\n                TextNode: {\n                    children: {\n                        SimpleTextNode: \"Don't you agree?\"\n                    }\n                }\n            }\n        }\n    }\n}\n```\n\n### ListNode\n[ListNode](/src/main/java/it/fulminazzo/markdownparser/nodes/ListNode.java)\nrepresents a **list block**.\nEvery item of the list will be loaded as [ListElements](/src/main/java/it/fulminazzo/markdownparser/nodes/ListElement.java),\nwhich are just another **wrapper** containing **any other node** (even another ListNode).\n\nTherefore, to **edit the contents** of a **ListNode**, you will have to access and modify its **ListElement** children.\n\n### CodeNode\n[CodeNode](/src/main/java/it/fulminazzo/markdownparser/nodes/CodeNode.java)\nrepresents a **code block**.\nIt supports both **single** and **triple quotes**, as well as **multi-lines** blocks:\n```markdown\n    `supports this`\n\n    ```and this```\n\n    ```java\n        System.out.println(\"Even this!\"\n    ```\n```\n**NOTE**: There is no operation to recognize the validity of the specified language, \nso anything specified in the correct format will be taken as such.\n\n### CommentNode\n[CommentNode](/src/main/java/it/fulminazzo/markdownparser/nodes/CommentNode.java)\nrepresents a **comment block**.\nIt supports both **Markdown** and **HTML comments**:\n```markdown\n[//]: # (This is supported)\n\u003c!-- This is also supported\nand allows for multilines!--\u003e\n```\nBy default, **CommentNode** will be **shown** when calling the `serialize()` method on them.\nThis is because **MarkdownParser**'s primary focus is to **programmatically create Markdown text**.\nHowever, if you want to **disable comments**, use `CommentNode#setVisible(boolean)`.\n\n### QuoteNode\n[QuoteNode](/src/main/java/it/fulminazzo/markdownparser/nodes/QuoteNode.java)\nrepresents a **quote block**.\nA quote ends when a **pair of new lines** (`\\n\\n`) is **found**, regardless of the spaces between them.\n\nFor example:\n```markdown\nQuoting Albert Einstein:\n\u003e Imagination is more important than knowledge.\nFor knowledge is limited,\n\u003e whereas imagination embraces the entire world, \nstimulating progress, giving birth to evolution.\n\nEnd of the quote.\n```\n\nWill only load as quote:\n```\nQuoteNode: {\n    content: \n    \u003e Imagination is more important than knowledge.\n    \u003e For knowledge is limited,\n    \u003e whereas imagination embraces the entire world,\n    \u003e stimulating progress, giving birth to evolution.\n}\n```\n\n### TableNode\n[TableNode](/src/main/java/it/fulminazzo/markdownparser/nodes/TableNode.java)\nrepresents a **table**.\nIn **MarkdownParser**, only a **maximum number of columns are supported**.\nYou can check them\nby invoking `Constants#getMaxTableLength()` from the [Constants class](/src/main/java/it/fulminazzo/markdownparser/utils/Constants.java).\n\nEvery **table row** will be loaded as a [TableRow](/src/main/java/it/fulminazzo/markdownparser/objects/TableRow.java)\nand will be **obtainable** using `TableNode#getTableRows()`.\nA **TableRow** loads its contents as [Nodes](#node),\nso you will have to access them using `TableRow#getContents()` to modify the row itself.\n\nAlso note that **TableNode** has a special row for the **titles**,\nwhich is retrievable using `TableNode#getTitleRow()`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffulminazzo%2Fmarkdownparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffulminazzo%2Fmarkdownparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffulminazzo%2Fmarkdownparser/lists"}