Skip to content

Commit 9f83116

Browse files
committed
Fixing a bug with wikilinks not working with relative path
1 parent 00909d8 commit 9f83116

File tree

9 files changed

+255
-3
lines changed

9 files changed

+255
-3
lines changed

markopolis/md.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import base64
33
import markdown
44
from typing import Dict, Optional, Any, Tuple, List
5-
from markdown.extensions.wikilinks import WikiLinkExtension
65
from .md_extensions import (
76
CalloutExtension,
87
MermaidExtension,
@@ -134,7 +133,8 @@ def get_note_content(note_path: str) -> Tuple[Optional[Tuple[str, str]], Optiona
134133
extensions=[
135134
"fenced_code",
136135
"codehilite",
137-
WikiLinkExtension(base_url="/", end_url=""),
136+
"mdx_wikilink_plus",
137+
# WikiLinkExtension(base_url="/", end_url=""),
138138
"markdown_checklist.extension",
139139
"markdown.extensions.tables",
140140
"footnotes",

markopolis/md/f1/test.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
publish: true
3+
---
4+
5+
Hello world

markopolis/md/f2/file2.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
publish: true
3+
---
4+
5+
Hello World

markopolis/md/f2/test.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
publish: true
3+
---
4+
5+
Hello World
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
---
2+
publish: true
3+
tags:
4+
- syntax
5+
- markdown
6+
---
7+
8+
# Headings
9+
10+
```markdown
11+
# Heading 1
12+
## Heading 2
13+
### Heading 3
14+
#### Heading 4
15+
##### Heading 5
16+
```
17+
18+
19+
# Heading 1
20+
## Heading 2
21+
### Heading 3
22+
#### Heading 4
23+
##### Heading 5
24+
25+
## Horizontal line
26+
27+
---
28+
29+
## Images
30+
31+
### embed images
32+
Image names should be unique. Duplicate images will be overwritten.
33+
34+
```markdown
35+
![[image.png]]
36+
```
37+
38+
![[image.png]]
39+
40+
### external images
41+
42+
```markdown
43+
![Engelbart](https://history-computer.com/ModernComputer/Basis/images/Engelbart.jpg)
44+
```
45+
46+
![Engelbart](https://history-computer.com/ModernComputer/Basis/images/Engelbart.jpg)
47+
48+
## Wikilinks
49+
50+
```markdown
51+
[[Installation]]
52+
[[f1/test]]
53+
[[f2/test]]
54+
```
55+
56+
[[Installation]]
57+
[[f1/test]]
58+
[[f2/test]]
59+
60+
## Text formatting
61+
```
62+
**Bold text**
63+
*Italic text*
64+
~~this puts a strikethrough~~
65+
==this highlights text==
66+
**Bold text and _nested italic_ text**
67+
***Bold and italic text***
68+
```
69+
70+
**Bold text**
71+
*Italic text*
72+
~~this puts a strikethrough~~
73+
==this highlights text==
74+
**Bold text and _nested italic_ text**
75+
***Bold and italic text***
76+
77+
## Footnotes
78+
79+
```markdown
80+
This is a simple footnote[^1].
81+
82+
83+
[^1]: This is the referenced text.
84+
[^2]: Add 2 spaces at the start of each new line.
85+
This lets you write footnotes that span multiple lines.
86+
[^note]: Named footnotes still appear as numbers, but can make it easier to identify and link references.
87+
```
88+
89+
This is a simple footnote[^1].
90+
91+
92+
## Quotes
93+
94+
```markdown
95+
> Human beings face ever more complex and urgent problems, and their effectiveness in dealing with these problems is a matter that is critical to the stability and continued progress of society.
96+
97+
\- Doug Engelbart, 1961
98+
```
99+
100+
> Human beings face ever more complex and urgent problems, and their effectiveness in dealing with these problems is a matter that is critical to the stability and continued progress of society.
101+
102+
\- Doug Engelbart, 1961
103+
104+
## Tables
105+
106+
```
107+
| First name | Last name |
108+
| ---------- | --------- |
109+
| Max | Planck |
110+
| Marie | Curie |
111+
```
112+
113+
| First name | Last name |
114+
| ---------- | --------- |
115+
| Max | Planck |
116+
| Marie | Curie |
117+
118+
The vertical bars on either side of the table are optional.
119+
120+
Cells don't need to be perfectly aligned with the columns. Each header row must have at least two hyphens.
121+
122+
```markdown
123+
First name | Last name
124+
-- | --
125+
Max | Planck
126+
Marie | Curie
127+
```
128+
129+
First name | Last name
130+
-- | --
131+
Max | Planck
132+
Marie | Curie
133+
134+
## Mermaid diagrams
135+
136+
Some text.
137+
138+
```mermaid
139+
graph TB
140+
A --> B
141+
B --> C
142+
```
143+
144+
```mermaid
145+
flowchart LR
146+
147+
148+
149+
A[Osaka 7-8] --> B[Tokyo 9-11]
150+
B -.Nagano .-> C[Matsumoto]
151+
C -.Nagano & Toyama.-> D[Takayama 12] <--> D1(Hida no Sato village)
152+
B -.Nagano & Toyama.-> D
153+
C <-.bus.-> D
154+
D --Toyama---> E <--> D2([Onsen 14]) --> F
155+
E[Kanazawa 13] ---> F[Kyoto 15-18] <--> F2(Uji) <--> F1(Nara)
156+
F <-.-> F4(Himeji)
157+
```
158+
159+
## Callouts
160+
161+
> [!abstract]
162+
> Lorem ipsum dolor sit amet
163+
164+
> [!info]
165+
> Lorem ipsum dolor sit amet
166+
167+
> [!todo]
168+
> Lorem ipsum dolor sit amet
169+
170+
> [!tip]
171+
> Lorem ipsum dolor sit amet
172+
173+
> [!success]
174+
> Lorem ipsum dolor sit amet
175+
176+
> [!question]
177+
> Lorem ipsum dolor sit amet
178+
179+
> [!warning]
180+
> Lorem ipsum dolor sit amet
181+
182+
> [!failure]
183+
> Lorem ipsum dolor sit amet
184+
185+
> [!danger]
186+
> Lorem ipsum dolor sit amet
187+
188+
> [!bug]
189+
> Lorem ipsum dolor sit amet
190+
191+
> [!example]
192+
> Lorem ipsum dolor sit amet
193+
194+
> [!quote]
195+
> Lorem ipsum dolor sit amet
196+
197+
> [!tip] Title-only callout
198+
199+
### Foldable callouts
200+
201+
You can make a callout foldable by adding a plus (+) or a minus (-) directly after the type identifier.
202+
203+
A plus sign expands the callout by default, and a minus sign collapses it instead.
204+
205+
> [!faq]-
206+
> Are callouts foldable?
207+
> Yes! In a foldable callout, the contents are hidden when the callout is collapsed.
208+
209+
[^1]: This is the referenced text.
210+
[^2]: Add 2 spaces at the start of each new line.
211+
This lets you write footnotes that span multiple lines.
212+
[^note]: Named footnotes still appear as numbers, but can make it easier to identify and link references.

markopolis/md/folder/file1.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
publish: true
3+
---
4+
5+
Hello world

markopolis/md/folder/file2.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
publish: true
3+
---
4+
5+
Hello world 2

poetry.lock

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ tqdm = "^4.66.5"
2222
jinja2 = "^3.1.4"
2323
fastapi = { extras = ["standard"], version = "^0.112.0" }
2424
markdown-checklist = "^0.4.4"
25+
mdx-wikilink-plus = "^1.4.1"
2526

2627
[tool.poetry.group.dev.dependencies]
2728
basedpyright = "*"

0 commit comments

Comments
 (0)