Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
caesr-pub
jekyll-scholar
Commits
51ec9fcd
Commit
51ec9fcd
authored
Sep 21, 2015
by
Sylvester Keil
Browse files
improve link conversion
see #101
parent
23419435
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
+46
-3
features/filter.feature
features/filter.feature
+31
-1
lib/jekyll/scholar/plugins/markdown_links.rb
lib/jekyll/scholar/plugins/markdown_links.rb
+15
-2
No files found.
features/filter.feature
View file @
51ec9fcd
...
...
@@ -140,8 +140,8 @@ Feature: BibTeX
|
key
|
value
|
|
source
|
./_bibliography
|
And I have the following BibTeX filters
:
|
latex
|
|
markdown
|
|
latex
|
And
I have a
"_bibliography"
directory
And I have a file "_bibliography/references.bib"
:
"""
...
...
@@ -164,3 +164,33 @@ Feature: BibTeX
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
And I should see "from \[https
:
//pragprog.com\]\(https
:
//pragprog.com\)"
in
"_site/scholar.html"
@tags
@urls
Scenario
:
LaTeX links as Markdown links
Given I have a scholar configuration with
:
|
key
|
value
|
|
source
|
./_bibliography
|
And I have the following BibTeX filters
:
|
markdown
|
|
latex
|
And
I have a
"_bibliography"
directory
And I have a file "_bibliography/references.bib"
:
"""
@book{pickaxe,
title = {Programming Ruby 1.9: The Pragmatic Programmer's Guide},
author = {Thomas, Dave and Fowler, Chad and Hunt, Andy},
year = {2009},
edition = 3,
publisher = {\href\{https://pragprog.com\}\{Pragmatic Bookshelf\}},
}
"""
And I have a page "scholar.html"
:
"""
---
---
{% bibliography %}
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
And I should see "\[Pragmatic Bookshelf\]\(https
:
//pragprog.com\)"
in
"_site/scholar.html"
lib/jekyll/scholar/plugins/markdown_links.rb
View file @
51ec9fcd
# Contri
u
bted by @mfenner
# Contrib
u
ted by @mfenner
# See https://github.com/inukshuk/jekyll-scholar/issues/30
require
'uri'
URL_PATTERN
=
Regexp
.
compile
([
'\\\\href\\\\{([^\\\\}]+)\\\\}\\\\{([^\\\\}]+)\\\\}'
,
URI
.
regexp
([
'http'
,
'https'
,
'ftp'
])
].
join
(
'|'
))
module
Jekyll
class
Scholar
class
Markdown
<
BibTeX
::
Filter
def
apply
(
value
)
value
.
to_s
.
gsub
(
URI
.
regexp
([
'http'
,
'https'
,
'ftp'
]))
{
|
c
|
"[
#{
$&
}
](
#{
$&
}
)"
}
value
.
to_s
.
gsub
(
URL_PATTERN
)
{
puts
$1
puts
$2
if
$1
"[
#{
$2
}
](
#{
$1
}
)"
else
"[
#{
$&
}
](
#{
$&
}
)"
end
}
end
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