Git Product home page Git Product logo

static-site-generator's People

Contributors

a-rokay avatar lmpham1 avatar roman-rezinkin avatar

Watchers

 avatar  avatar

static-site-generator's Issues

Remove hardcoded pygments stylesheet reference from html_skeleton

The pygments.css reference should only be applied to markdown files, because they are the only files to generate and use pygments.css. This will probably need to be done in the generate_html function.

html_skeleton = """<!doctype html>
<html lang="{lang}">
<head>
    <meta charset="utf-8">
    <title>{title}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../assets/css/pygments.css">{stylesheet}
</head>
<body>
{content}
</body>
</html>
"""

Lab 4: Support --config with Config File

For this issue, I will be implementing a new feature to the static-site-generator.

This new feature will allow the ability to use a config file within the static-site-generator to allow users to specify the config file instead of typing out all of the necessary command arguments. This will clean up the user's input, and allow for quick modification of arguments on the user's end.

The config file will be JSON formatted. Use below as an example.

{
  "input": "./docs",
  "output": "./web",
  "future-feature": "should be ignored for now"
}

The command line will be able to do this.

{ 
Option 1: use command line arguments:
ssg --input ./site --output ./build --stylesheet https://cdn.jsdelivr.net/npm/water.css@2/out/water.css --lang fr

Option 2: use a config file
ssg --config ./ssg-config.json
}

Add full markdown support

Currently, a lot of markdown features are missing. I'm looking at implementing this library to bring in more features. The library has a markdown function that takes in a markdown string and returns html, the same signature we have in our process_markdown function.

html = markdown.markdown(your_text_string)

So, I'll simply replace the logic in process_markdown with the new library's processing.

Simplify mark down parsing

Currently, the markdown parsing for bold and italics seems overcomplicated. I will try to simplify it by removing the lambda statements and using groups.

Adding support for setting language

I will add a new passable argument "--lang"/"-l", that allows the user to set the language of the generated html. The language they pass will be set in the root html tag like so:

ssg.py -i input.txt -l pt-BR
input.html
<!doctype html>
<html lang="pt-BR">
...

If the lang argument is not used, "en" will be set as the language.

"Add asset" function

There needs a function that allows us to add assets to the asset folder. As an example, I'm currently working on issue #12, which requires an external CSS stylesheet for highlighted code blocks. I need to be able to create a CSS asset folder in dist/assets/ that contains the stylesheet.

Add Markdown Support

I would like to add markdown support to your SSG. The following functionalities will be added:

  • The program accepts .md files as input
  • Bold markdown syntax is supported (for example __test__ or **test** will become "test")
  • Italics markdown syntax is supported (for example _test_ or *test* will become "test")
  • Heading 1, Heading 2 and Heading 3 are supported (for example # test will become <h1>test</h1> etc.)

After reviewing and testing your code, I have come up with the following plan:

  • I will modify the get_txt_files() function to add filtering for .md file
  • I see that your program filters folder input for .txt files, but does not have an equivalent method to validate file input yet, so I'll also add a file input validator function that will only accept .txt and .md as supported file input
  • Your program generates HTML files by using a path that includes file_name.replace(".txt", ".html"). I will modify this to add support for .md files.
  • I will create a separate function called process_content() to check for markdown syntax and process them. Then I will call this function inside your generate_content() function. I believe this approach will make it easier to modify the markdown processing algorithm in the future

Please let me know if you have any questions or suggestions regarding this plan.

Create an index page

A main index.html with links to each page should be created and stored in dist.

Generated files should be put in their own folders

Generated files should be put in their own folders as index.html, similar to docusaurus:

image

This will help keep the hierarchy clean and the url for each page will look more professional. I also think there should be an assets folder that holds CSS, images, etc.

Working on issue #12, I've realized that I need a local CSS file that holds the styling for each code highlight. The assets folder could be generated from main and populated when needed.

Improve readme.md

Please add the python version required and make the readme more informative. You can also share code if you like.

Split up and explain the various usage examples

There are a number of Usage examples given, but no explanation for any of them or what they do. Later you list the help output, but it would be good to give some explanation of how each of the different args/flags work, when to use them, how to combine them, etc.

Properly parse out file name in output_to_file

Currently, the method of getting the file_name is not robust.

def output_to_file(file_name, html):
    file_name = file_name.replace(file_name[file_name.rfind("."):], "")
    ...

The current method simply strips the extenstion which leads to errors if the input is a single file that resides in a folder.

FileNotFoundError: [WinError 3] The system cannot find the path specified: 'dist/Sherlock Holmes Selected Stories/test'

Also, the file_name parameter is not named properly, it should be file.

Adding support for inline code blocks

I will expand the markdown parser to include inline code blocks. Text encased by single backticks will be encased in <code> tags in the resulting html, like so:

input.txt
1234 `567` 89
input.html
1234 <code>567</code> 89

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.