Skip to content

Commit 17d6b48

Browse files
Merge pull request #2 from encode/img
Fix img linking
2 parents c7e09b4 + de07be2 commit 17d6b48

6 files changed

Lines changed: 27 additions & 28 deletions

File tree

docs/img/codercat.png

55.4 KB
Loading

docs/styling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The base template for rendering is `templates/base.html`:
3535

3636
You can override this template locally and adapt it to make layout changes.
3737

38-
## Media assets
38+
## Media
3939

4040
The default theme includes the following assets:
4141

docs/writing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ These are the elements outlined in John Gruber’s original design document. All
4040

4141
## Link
4242

43-
[About](ABOUT.md)
43+
[Homepage](index.md)
4444

4545
## Image
4646

47-
![calt text](img/codercat.jpg)
47+
![coder cat](img/codercat.png)
4848

4949
## Table
5050

@@ -103,7 +103,7 @@ Here's a sentence with a footnote. [^1]
103103

104104
`@octocat :+1: This PR looks great - it's ready to merge! :shipit:`
105105

106-
@octocat :+1: This PR looks great - it's ready to merge! :shipit:
106+
@octocat :+1: This PR looks great :heart: - it's ready to merge! :shipit:
107107

108108
### Task List
109109

src/mkdocs/mkdocs.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ def read(self, path: pathlib.Path) -> bytes:
5555
"""
5656
return ''
5757

58-
def name(self) -> str:
59-
return ''
60-
6158

6259
class Directory(Handler):
6360
"""
@@ -78,9 +75,6 @@ def load_paths(self) -> list[pathlib.Path]:
7875
def read(self, path: pathlib.Path) -> bytes:
7976
return self._dir.joinpath(path).read_bytes()
8077

81-
def name(self) -> str:
82-
return 'docs'
83-
8478
def __repr__(self):
8579
return f'<Directory {self._dir_repr}>'
8680

@@ -112,9 +106,6 @@ def load_paths(self) -> list[pathlib.Path]:
112106
def read(self, path: pathlib.Path) -> bytes:
113107
return self._files.joinpath(path).read_bytes()
114108

115-
def name(self) -> str:
116-
return 'theme'
117-
118109
def __repr__(self):
119110
return f'<Package {self._pkg!r}>'
120111

@@ -137,7 +128,7 @@ def read(self) -> bytes:
137128
return self.handler.read(self.path)
138129

139130
def __repr__(self) -> str:
140-
return f'<Resource {self.url!r} {self.path.as_posix()!r} [{self.handler.name()}]>'
131+
return f'<Resource {self.url!r} {self.path.as_posix()!r}>'
141132

142133

143134
class Template:
@@ -150,7 +141,7 @@ def read(self) -> bytes:
150141
return self.handler.read(self.path)
151142

152143
def __repr__(self) -> str:
153-
return f'<Template {self.path.as_posix()!r} [{self.handler.name()}]>'
144+
return f'<Template {self.name!r}>'
154145

155146

156147
class TemplateLoader(jinja2.BaseLoader):
@@ -194,9 +185,6 @@ def path_to_url(self, path: pathlib.Path) -> str:
194185
# 'css/styles.css' -> '/css/styles.css'
195186
return pathlib.Path('/').joinpath(path).as_posix()
196187

197-
def log(self, msg: str) -> None:
198-
print(msg)
199-
200188
def load_config(self, filename: str) -> dict:
201189
path = pathlib.Path(filename)
202190
if not path.exists():
@@ -230,10 +218,10 @@ def load_config(self, filename: str) -> dict:
230218
# {'title': 'Themes & styling', 'path': 'styling.md'},
231219
# ],
232220
},
233-
# 'handlers': {
234-
# 'theme': {'type': 'mkdocs.Package', 'pkg': 'mkdocs:theme'}
235-
# 'docs': {'type': 'mkdocs.FileSystem', 'dir': 'docs'}
236-
# },
221+
# 'handlers': [
222+
# {'type': 'mkdocs.Package', 'pkg': 'mkdocs:theme'}
223+
# {'type': 'mkdocs.Directory', 'dir': 'docs'}
224+
# ],
237225
'markdown': {
238226
'extensions': {
239227
'fenced_code',
@@ -329,7 +317,6 @@ def build(self):
329317
for resource in resources:
330318
output = self.render(resource, resources, config, env, md)
331319
build_path = buildpath.joinpath(resource.output_path)
332-
self.log(build_path)
333320
build_path.parent.mkdir(parents=True, exist_ok=True)
334321
build_path.write_bytes(output)
335322

src/mkdocs/rewrite_urls.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,22 @@ def run(self, root):
2727
ctx = page_context.get()
2828
links = []
2929
idx = 0
30+
key = ''
31+
link = ''
3032

31-
for el in root.iter('a'):
32-
href = el.get('href')
33-
if href:
34-
url = httpx.URL(href)
33+
for el in root.iter():
34+
if el.tag == 'a':
35+
key = 'href'
36+
link = el.get(key)
37+
elif el.tag == 'img':
38+
key = 'src'
39+
link = el.get(key)
40+
else:
41+
key = ''
42+
link = ''
43+
44+
if link:
45+
url = httpx.URL(link)
3546
if url.is_relative_url and url._uri_reference.path:
3647
from_path = ctx.path
3748
to_path = ctx.path.parent.joinpath(url.path)
@@ -46,7 +57,7 @@ def run(self, root):
4657
rewrite += f'?{url.query}'
4758
if url.fragment:
4859
rewrite += f'#{url.fragment}'
49-
el.set('href', rewrite)
60+
el.set(key, rewrite)
5061
links.append({"title": el.text, "url": rewrite})
5162

5263
if from_url == to_url:

src/mkdocs/short_codes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'bug': '🐛',
1414
'thinking': '🤔',
1515
'eyes': '👀',
16+
'shipit': '🚢',
1617
}
1718

1819

0 commit comments

Comments
 (0)