Author: eric-cc-su
RLAssembly (Reading List Assembly) is a command-line Ruby script to read an HTML or Markdown file of categorized links and convert it to JSON. (Because I'm lazy and automation is cool)
RLAssembly was conceived to be used alongside my GitHub Pages/Jekyll site to objectify a reading list of links to articles and websites. It is not currently (06/23/15) constructed as a Jekyll plugin.
#Using RLAssembly
In a terminal, cd to the RLAssembly directory and execute the script with the following command:
ruby RLAssembly.rb *FILEPATH*
##Arguments
FILEPATH
- REQUIRED - The path of the file to be analyzed for JSON extraction. This can be an absolute or a relative path.
#Files
- Input File:
*/*.md
OR*/*.html
- Output File:
*/reading-list.json
The output file reading-list.json
will be written in the same directory as the input file.
#Formatting
###HTML
<h3>Non-Category Header</h3>
<h2 class="rlcat">Category Header</h2>
<p>text that will not be analyzed...</p>
<ul>
<li><a href="http://www.URL1.com/">URL1</a></li>
<li><a href="https://URL2.com">URL2</a></li>
</ul>
- Categories must be an
<h#>
element with the classrlcat
otherwise it will be ignored (avoids creating unwanted categories) - links must be list items in the format:
<li><a ...>*TITLE*</a></li>
- link tag
<a>
must immediately follow<li>
- the
*TITLE*
of the link must be followed by the closing tags</a></li>
. Therefore*TITLE*
cannot be enclosed by any other tags
- link tag
- You may use any classes and tag parameters in your HTML as long as the above points are still satisfied
###Markdown Markdown file format:
#Category
[URL Title](https://www.url.com)
[URL2 Title](https://www.url2.com)-category2
##Category2
...
...
Any header within the Markdown file will be converted into a category.
ALTERNATIVELY
Markdown single line format: [URL Title]("https://www.url.com")-category
- there should be no whitespace between the URL parentheses and the hyphen
- whitespace between the hyphen and the character will be stripped
- a hyphenated category will override the header category
- Categories will be automatically capitalized when converted to JSON
- Any leading whitespace will be stripped from the category name
###JSON JSON output format:
{
"Category": [
{
"title": "URL Title",
"url": "https://www.url.com",
},
{...},
{...}
],
"Category2": [
{
"title": "URL2 Title",
"url": "https://www.url2.com",
},
{...},
{...}
]
}
This code is licensed under the MIT License and under copyright by Eric Su