Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
docs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
docs
Commits
ae9d7481
Commit
ae9d7481
authored
Nov 07, 2017
by
Tobias Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle embedded images in repository docs
parent
b20ed77d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
Rules
Rules
+8
-0
normalize_links.rb
lib/filters/normalize_links.rb
+6
-2
No files found.
Rules
View file @
ae9d7481
...
@@ -33,6 +33,14 @@ route '/assets/*' do
...
@@ -33,6 +33,14 @@ route '/assets/*' do
end
end
end
end
# TODO(ts): Remove these hacks once the nanoc4 upgrade is done.
compile
'*/images/*'
do
end
route
'*/images/*'
do
item
.
identifier
.
chop
+
'.'
+
item
[
:extension
]
end
route
'/README/'
do
route
'/README/'
do
'/README.md'
'/README.md'
end
end
...
...
lib/filters/normalize_links.rb
View file @
ae9d7481
...
@@ -9,9 +9,8 @@ class NormalizeLinks < ::Nanoc::Filter
...
@@ -9,9 +9,8 @@ class NormalizeLinks < ::Nanoc::Filter
def
run
(
content
,
config
=
{})
def
run
(
content
,
config
=
{})
doc
=
Nokogiri
::
HTML
(
content
)
doc
=
Nokogiri
::
HTML
(
content
)
links
=
doc
.
xpath
(
'//a'
)
links
.
each
do
|
link
|
doc
.
xpath
(
'//a'
)
.
each
do
|
link
|
link
[
'href'
]
=
link
[
'href'
]
=
case
case
when
link
[
'href'
].
start_with?
(
DOMAIN
)
when
link
[
'href'
].
start_with?
(
DOMAIN
)
...
@@ -26,6 +25,11 @@ class NormalizeLinks < ::Nanoc::Filter
...
@@ -26,6 +25,11 @@ class NormalizeLinks < ::Nanoc::Filter
end
end
end
end
doc
.
xpath
(
'//img'
).
each
do
|
img
|
next
if
img
[
'src'
].
start_with?
(
'/'
)
||
img
[
'src'
].
start_with?
(
'http'
)
img
[
'src'
]
=
File
.
join
(
"../"
,
img
[
'src'
])
end
doc
.
to_s
doc
.
to_s
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment