Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .ameba.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ Naming/QueryBoolMethods:
Naming/BlockParameterName:
Comment thread
nobodywasishere marked this conversation as resolved.
Enabled: false

Style/UnlessElse:
Enabled: false

Style/ParenthesesAroundCondition:
Comment thread
nobodywasishere marked this conversation as resolved.
Enabled: false
Comment thread
nobodywasishere marked this conversation as resolved.
Outdated

Style/NegatedConditionsInUnless:
Enabled: false
AllowSafeAssignment: true

Lint/NotNil:
Excluded:
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ def extract_spec_tests(file)
result_start = false

begin
File.open(file) do |f|
File.open(file) do |input|
line_number = 0
test_tags = ""

while line = f.read_line
while line = input.read_line
line_number += 1
line = line.gsub(/\r\n?/, "\n")
break if line.includes?("<!-- END TESTS -->")
Expand Down
4 changes: 2 additions & 2 deletions src/markd/parsers/block.cr
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ module Markd::Parser
add_line

# if HtmlBlock, check for end condition
if (container_type.html_block? && match_html_block?(container))
if container_type.html_block? && match_html_block?(container)
token(container, @current_line)
end
elsif @offset < line.size && !@blank
Expand All @@ -196,7 +196,7 @@ module Markd::Parser
private def process_inlines
walker = @document.walker
@inline_lexer.refmap = @refmap
while (event = walker.next)
while event = walker.next
node, entering = event
if !entering && (node.type.paragraph? || node.type.heading? || node.type.table_cell?)
@inline_lexer.parse(node)
Expand Down
8 changes: 4 additions & 4 deletions src/markd/parsers/inline.cr
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,7 @@ module Markd::Parser
case closer_char
when '*', '_', '~'
if closer_char != '~' || (closer_char == '~' && @options.gfm)
unless opener
closer = closer.next?
else
if opener
# calculate actual number of delimiters used from closer
use_delims = (closer.num_delims >= 2 && opener.num_delims >= 2) ? 2 : 1

Expand Down Expand Up @@ -444,6 +442,8 @@ module Markd::Parser
remove_delimiter(closer)
closer = tmp_stack
end
else
closer = closer.next?
end
end
when '\''
Expand Down Expand Up @@ -600,7 +600,7 @@ module Markd::Parser
end

text = @text.byte_slice((@pos + 1), (pos - 1) - (@pos + 1))
if (emoji = EmojiEntities::EMOJI_MAPPINGS[text]?)
if emoji = EmojiEntities::EMOJI_MAPPINGS[text]?
@pos = pos
node.append_child(text(emoji))

Expand Down
2 changes: 1 addition & 1 deletion src/markd/renderers/html_renderer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ module Markd
def strong(node : Node, entering : Bool) : Nil
@strong_stack -= 1 if @options.gfm && !entering

tag("strong", end_tag: !entering) if (@strong_stack == 0)
tag("strong", end_tag: !entering) if @strong_stack == 0

@strong_stack += 1 if @options.gfm && entering
end
Expand Down
10 changes: 5 additions & 5 deletions src/markd/rules/html_block.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module Markd::Rule
block_type_size = Rule::HTML_BLOCK_OPEN.size - 1

Rule::HTML_BLOCK_OPEN.each_with_index do |regex, index|
if (text.match(regex) &&
(index < block_type_size || !container.type.paragraph?))
if text.match(regex) &&
(index < block_type_size || !container.type.paragraph?)
parser.close_unmatched_blocks
# We don't adjust parser.offset;
# spaces are part of the HTML block:
Expand Down Expand Up @@ -47,18 +47,18 @@ module Markd::Rule
end

def self.escape_disallowed_html(text : String) : String
String.build do |s|
String.build do |string|
pos = 0

text.scan(/<\/?\s*(#{GFM_DISALLOWED_HTML_TAGS.join('|')})\b/i) do |match|
start = text.index(match[0], pos)
next if start.nil?

s << text[pos...start] << "&lt;#{match[0][1..]}"
string << text[pos...start] << "&lt;#{match[0][1..]}"
pos = start + match[0].size
end

s << text[pos..-1]
string << text[pos..-1]
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions src/markd/rules/list.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ module Markd::Rule
ORDERED_LIST_MARKERS = {'.', ')'}

def match(parser : Parser, container : Node) : MatchValue
if (!parser.indented || container.type.list?)
if !parser.indented || container.type.list?
data = parse_list_marker(parser, container)
return MatchValue::None unless data && !data.empty?
return MatchValue::None if !data || data.empty?

parser.close_unmatched_blocks
if !parser.tip.type.list? || !list_match?(container.data, data)
Expand Down Expand Up @@ -167,7 +167,7 @@ module Markd::Rule
while container
return true if container.last_line_blank?

break unless !container.last_line_checked? && container.type.in?(Node::Type::List, Node::Type::Item)
break if container.last_line_checked? || !container.type.in?(Node::Type::List, Node::Type::Item)
container.last_line_checked = true
container = container.last_child?
end
Expand Down
4 changes: 2 additions & 2 deletions src/markd/rules/table.cr
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ module Markd::Rule
def token(parser : Parser, container : Node) : Nil
lines = container.text.strip.split("\n")

row_sizes = lines[...2].map do |l|
strip_pipe(l.strip).split(TABLE_CELL_SEPARATOR).size
row_sizes = lines[...2].map do |line|
strip_pipe(line.strip).split(TABLE_CELL_SEPARATOR).size
end.uniq!

# Do we have a real table?
Expand Down