Class: Kramdown::Parser::GFM
- Inherits:
-
Kramdown
- Object
- Kramdown
- Kramdown::Parser::GFM
- Defined in:
- lib/jekyll-theme-cs50.rb
Instance Method Summary collapse
- #parse_autolink ⇒ Object
- #parse_link ⇒ Object
-
#parse_list ⇒ Object
Remember list markers.
Instance Method Details
#parse_autolink ⇒ Object
554 555 556 557 558 559 560 561 562 563 564 |
# File 'lib/jekyll-theme-cs50.rb', line 554 def parse_autolink super # Get autolink current_link = @tree.children.select{ |element| [:a].include?(element.type) }.last unless current_link.nil? # Hide scheme and trailing slash current_link.children[0].value = current_link.children[0].value.gsub(/^https?:\/\/(www.)?|\/$/, "") end end |
#parse_link ⇒ Object
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
# File 'lib/jekyll-theme-cs50.rb', line 566 def parse_link super # Get link current_link = @tree.children.select{ |element| [:a].include?(element.type) }.last unless current_link.nil? # If inline link ends with .md if match = current_link.attr["href"].match(/\A([^\s]*)\.md(\s*.*)\z/) # Rewrite as /, just as jekyll-relative-links does current_link.attr["href"] = match.captures[0] + "/" + match.captures[1] end end end |
#parse_list ⇒ Object
Remember list markers
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
# File 'lib/jekyll-theme-cs50.rb', line 583 def parse_list super # Get list current_list = @tree.children.select{ |element| [:ul].include?(element.type) }.last unless current_list.nil? # For each li current_list.children.each do |li| # Line number of li location = li.[:location] # Determine marker, might be nested inside of a blockquote # https://kramdown.gettalong.org/syntax.html#blockquotes li.attr["data-marker"] = @source.lines[location-1].sub(/^[\s>]*/, "")[0] end end true end |