mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-01 13:24:25 +01:00
Merge pull request #2 from twbs/data-example-id
Add support for example IDs to {% example %} template tag
This commit is contained in:
commit
fc9b7e5464
@ -8,7 +8,7 @@ module Jekyll
|
|||||||
# forms: name, name=value, or name="<quoted list>"
|
# forms: name, name=value, or name="<quoted list>"
|
||||||
#
|
#
|
||||||
# <quoted list> is a space-separated list of numbers
|
# <quoted list> is a space-separated list of numbers
|
||||||
SYNTAX = /^([a-zA-Z0-9.+#-]+)((\s+\w+(=(\w+|"([0-9]+\s)*[0-9]+"))?)*)$/
|
SYNTAX = /^([a-zA-Z0-9.+#-]+)((\s+\w+(=((\w|[0-9_-])+|"([0-9]+\s)*[0-9]+"))?)*)$/
|
||||||
|
|
||||||
def initialize(tag_name, markup, tokens)
|
def initialize(tag_name, markup, tokens)
|
||||||
super
|
super
|
||||||
@ -17,7 +17,7 @@ module Jekyll
|
|||||||
@options = {}
|
@options = {}
|
||||||
if defined?($2) && $2 != ''
|
if defined?($2) && $2 != ''
|
||||||
# Split along 3 possible forms -- key="<quoted list>", key=value, or key
|
# Split along 3 possible forms -- key="<quoted list>", key=value, or key
|
||||||
$2.scan(/(?:\w="[^"]*"|\w=\w|\w)+/) do |opt|
|
$2.scan(/(?:\w+(?:=(?:(?:\w|[0-9_-])+|"[^"]*")?)?)/) do |opt|
|
||||||
key, value = opt.split('=')
|
key, value = opt.split('=')
|
||||||
# If a quoted list, convert to array
|
# If a quoted list, convert to array
|
||||||
if value && value.include?("\"")
|
if value && value.include?("\"")
|
||||||
@ -55,7 +55,7 @@ eos
|
|||||||
end
|
end
|
||||||
|
|
||||||
def example(output)
|
def example(output)
|
||||||
"<div class=\"bs-example\">#{output}</div>"
|
"<div class=\"bs-example\" data-example-id=\"#{@options[:id]}\">\n#{output}\n</div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_rouge(code)
|
def render_rouge(code)
|
||||||
|
Loading…
Reference in New Issue
Block a user