Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: markdown template #96

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

straight-into-the-wall
Copy link

What does this implement/fix? Explain your changes.

Artifacts could now be parsed as markdown documents and rendered in color.
It uses rich which implements commonmark standards and several themes.

Does this close any currently open issues?

No. It's a new feature.

Any relevant logs, error output, etc?

No.

Any other comments?

Discovered this repo today and fits pretty well my needs, except that I already have a knowledge base in form of markdown documents. This is my attempt to fill this gap.

Before pushing I've run all the tests and linters in the makefile; these fixes covers several files resulting in quite a bit of noise around the actual implementation of the functionality that is instead grouped in the commit 45e000e.

Where has this been tested?

Operating System: Arch

Platform: Linux

Target Platform: Linux desktop

OS: Arch Linux x86_64
Host: XPS 15 9570
Kernel: 5.14.16-arch1-1
Shell: bash 5.1.8
Resolution: 1920x1080
WM: i3
Terminal: alacritty
CPU: Intel i7-8750H (12) @ 4.100GHz

@gnebbia
Copy link
Owner

gnebbia commented Nov 22, 2021

I am sorry, could you please provide an example of how this works?
I am confused about the reason to implement this, since the user could just put a couple of regex for simple markdown syntax highlighting in the config file. What am I missing? Could you provide some example maybe with some example file?

@straight-into-the-wall
Copy link
Author

straight-into-the-wall commented Nov 22, 2021

Thank you for your kind response.

As an example you could try:

kb add kb/README.md --template="markdown"
kb view README.md

But I'll be happy to add an example to the PR if you wish, and maybe some documentation.

Sure you can use the existing functionalities to highlight the content of an artifact, but I think that parsing a CommonMark documents goes a little further than that.
I think for example at code blocks, block quotes, headings hierarchy, bold and italic, etc.

As a bonus it comes with a variety of predefined well known themes you can choose from and some global formatting options like console padding and paging.

Here are some screenshots of the kb README.md with the default markdown config that use the paraiso-dark theme:

kb_rich_001

kb_rich_002

@gnebbia
Copy link
Owner

gnebbia commented Nov 25, 2021

Ok thanks for everything but before integrating I still need additional information...
How does this work with the template stuff?
If I do kb template list i don't see any "markdown", and also where could a user apply a theme as you mentioned the "paraiso-dark"?

@straight-into-the-wall
Copy link
Author

straight-into-the-wall commented Nov 26, 2021

Hi, thanks for your time ... and your project.

If I type kb template list, I've got:

image

And with kb template edit markdown (using nano as editor):

image

The default markdown template is defined right after the general default template in config.py:

image

For me this is behavior is reproduced with :

  • git checkout md_template
  • git pull
  • python -m kb template list in the projet root folder

After make reinstall I can see it anywhere in the filesystem.

@gnebbia
Copy link
Owner

gnebbia commented Nov 26, 2021

Ok thanks for the patience, unlikely when I try:
python -m kb template list
I only get the default theme, am I missing something?

(Of course after I fetched your pull request).
Maybe could you try to do it on a clean environment, so that we can see if there is something missing?

@straight-into-the-wall
Copy link
Author

straight-into-the-wall commented Nov 26, 2021

All clear here.

  • create a new lubuntu based vm on virtualbox
  • git clone https://github.com/straight-into-the-wall/kb.git
  • cd kb
  • git checkout md_template
  • pip3 install -r requirements.txt
  • python3 -m setup install
  • kb template list

image

@gnebbia
Copy link
Owner

gnebbia commented Dec 5, 2021

I am sorry I am really not able to reproduce what you have, may it be some file you have on your system that is missing on my machine?

@straight-into-the-wall
Copy link
Author

Hi, thanks for your response.

I think that having reproduced the desired behavior in a vm remove the likelihood of any dependencies with local configurations and other files.

Had you tried to start a vm and follow the exact steps listed in my previous post?

@tacgnol
Copy link

tacgnol commented Aug 23, 2022

I just came across this issue myself. If this is tried on an existing system the logic in initializer.py will prevent the new markdown template being created due to the existence of the templates directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants