Code Monkey home page Code Monkey logo

pelican-obsidian's Introduction

Obsidian: A Plugin for Pelican

Obsidian is a pelican plugin that allows you to use the syntax used within Obsidian and when pelican then renders these posts it won't look weird or out of place.

Phrased differently, if you don't like that # is included in the name of the tag when you name it #my-tag and you think that internal pelican links are difficult to remember and would like to use [[ my link ]] as an internal link instead this plugin would be for you.

If the article doesn't exist it will return text only. That way, there is a possibility of clearly separating posts that should belong on the blog and linked as such vs posts that should only belong inside Obsidian.

Installation

This plugin can be installed via:

# not yet on pypi, but when it is you can install it with.
pip install pelican-obsidian

# meanwhile you can install using this repo.
pip install git+git://github.com/jonathan-s/pelican-obsidian@main#egg=pelican-obsidian

Add 'obsidian' to the PLUGINS list in your Pelican config:

PLUGINS = [
    'obsidian',
]

Usage

In the tags section you will be able to use # without that being reflected in the actual name of the tag. In other words.

Tags: #my-tag

# reflects as
my-tag in the html output.

Links follow this format:

[[note name]]
[[note name | custom link text]]

Files are similar:

![[photo.jpg]]
![[photo.jpg | custom alt text]]

They explain more about the syntax in the section on how to embed files

Future features

  • Embed files or sections as described here
  • Task list?
  • Support .rst?
  • don't generate links for drafts

Implemented Features

  • Apply the same linking for pages.

License

This project is licensed under the MIT license.

pelican-obsidian's People

Contributors

acherrera avatar jonathan-s avatar tannercollin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pelican-obsidian's Issues

Tag Format Issue

Tags Messing Up During Formatting

I have frontmatter in my markdown files that looks like the following. The format of the tags here works as expected:

---
Title: Some  Recipe
Date: 2023-11-13
Slug: some_recipe
tags: food, recipe, vegetarian, bread
Author: acherrera
Summary: How to make something
---

However, when the tags are formatted as the following, it does not work as expected:

tags
 - food
 - recipe
 - vegetarian
 - bread

Instead, everything from tags down is rendered as Markdown instead of being put in the metadata. I thought it was due to the metadata tag converter, but it appears to be in the link formatter. Removing all wikilinks from the post causes the tags to be processed as expected.

Bug when running on windows

When running on windows, there is an issue with the formatting and how it interacts with pelican formatting. The first indication of this issue was the URLS were showing up like this: http://127.0.0.1:8000/%7Bfilename%7D/reference/Databricks/Databricks Tables.md

In the section of code where the paths are assigned and built:

filename, linkname = get_file_and_linkname(match)
path = ARTICLE_PATHS.get(filename)
if path:
link_structure = '[{linkname}]({{filename}}{path}{filename}.md)'.format(
linkname=linkname, path=path, filename=filename
)

I added some debug line to see what was going on.

Path: \reference\Databricks/
Filename: Databricks Tables
Fullpath: \reference\Databricks/Databricks Tables
Replaced Link:[Databricks Tables]({filename}\reference\Databricks/Databricks Tables.md)

I suspected that the two slashes - back and forward slash - were causing issues. After going in and manually putting links in markdown files it was discovered that ANY backslashes do not work correctly.

Doesn't work: [Databricks Tables]({filename}\reference\Databricks\Databricks Tables.md)
Doesn't work: [Databricks Tables]({filename}\reference\Databricks/Databricks Tables.md)
Does work: [Databricks Tables]({filename}/reference/Databricks/Databricks Tables.md)

Because of this behavior, I think that this issue is actually with how Pelican parses links - it jsut doesn't work with Windows style links

Solution:
Replace all separators with forward slashes regardless of operating system:

link_structure = link_structure.replace(os.sep, '/')

I plan on making a PR for this soon, but this is a temporary work around until then.

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.