Skip to content
This repository has been archived by the owner on Dec 28, 2022. It is now read-only.

Commit

Permalink
refactor: cancel generic block with attributes only
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed May 15, 2016
1 parent 5e202ea commit 42989ec
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 75 deletions.
27 changes: 0 additions & 27 deletions grammars/language-asciidoc.cson
Original file line number Diff line number Diff line change
Expand Up @@ -2679,33 +2679,6 @@ repository:
}
]
}
{
begin: "^\\[([^\\]]+)\\]$"
beginCaptures:
"0":
name: "support.asciidoc"
"1":
name: "markup.meta.attribute-list.asciidocc"
end: "(?<=----)[\\r\\n]+$"
patterns: [
{
name: "markup.raw.asciidoc"
begin: "^(-{4,})\\s*$"
beginCaptures:
"0":
name: "support.asciidoc"
patterns: [
{
include: "#block-callout"
}
]
end: "^\\1*$"
endCaptures:
"0":
name: "support.asciidoc"
}
]
}
{
name: "markup.raw.asciidoc"
begin: "^(-{4,})\\s*$"
Expand Down
20 changes: 0 additions & 20 deletions lib/code-block-generator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,6 @@ module.exports =
0: name: 'support.asciidoc'
]

# add generic block with attributes only
codeBlocks.push
begin: '^\\[([^\\]]+)\\]$'
beginCaptures:
0: name: 'support.asciidoc'
1: name: 'markup.meta.attribute-list.asciidocc'
end: '(?<=----)[\\r\\n]+$'
patterns: [
name: 'markup.raw.asciidoc'
begin: '^(-{4,})\\s*$'
beginCaptures:
0: name: 'support.asciidoc'
patterns: [
include: '#block-callout'
]
end: '^\\1*$'
endCaptures:
0: name: 'support.asciidoc'
]

# add listing block
codeBlocks.push
name: 'markup.raw.asciidoc'
Expand Down
33 changes: 5 additions & 28 deletions spec/code-block-generator-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe 'Code block generator', ->
it 'should generate default code block', ->
languages = []
codeBlocks = generator.makeAsciidocBlocks(languages)
expect(codeBlocks).toHaveLength 3 # Number of blocks
expect(codeBlocks).toHaveLength 2 # Number of blocks
expect(codeBlocks[0]).toEqualJson
begin: '^\\[(source)(,([^\\]]*))?\\]$'
beginCaptures:
Expand All @@ -28,34 +28,11 @@ describe 'Code block generator', ->
0: name: 'support.asciidoc'
]

it 'should generate default code block with attributes only', ->
languages = []
codeBlocks = generator.makeAsciidocBlocks(languages)
expect(codeBlocks).toHaveLength 3 # Number of blocks
expect(codeBlocks[1]).toEqualJson
begin: '^\\[([^\\]]+)\\]$'
beginCaptures:
0: name: 'support.asciidoc'
1: name: 'markup.meta.attribute-list.asciidocc'
end: '(?<=----)[\\r\\n]+$'
patterns: [
name: 'markup.raw.asciidoc'
begin: '^(-{4,})\\s*$'
beginCaptures:
0: name: 'support.asciidoc'
patterns: [
include: '#block-callout'
]
end: '^\\1*$'
endCaptures:
0: name: 'support.asciidoc'
]

it 'should generate listing block', ->
languages = []
codeBlocks = generator.makeAsciidocBlocks(languages)
expect(codeBlocks).toHaveLength 3 # Number of blocks
expect(codeBlocks[2]).toEqualJson
expect(codeBlocks).toHaveLength 2 # Number of blocks
expect(codeBlocks[1]).toEqualJson
name: 'markup.raw.asciidoc'
begin: '^(-{4,})\\s*$'
beginCaptures:
Expand All @@ -72,7 +49,7 @@ describe 'Code block generator', ->
pattern: 'javascript|js', type: 'source', code: 'js'
]
codeBlocks = generator.makeAsciidocBlocks(languages)
expect(codeBlocks).toHaveLength 4 # Number of blocks
expect(codeBlocks).toHaveLength 3 # Number of blocks
expect(codeBlocks[0]).toEqualJson
begin: '^\\[(source),\\p{Blank}*(?i:(javascript|js))(?:,([^\]]*))?\\]$'
beginCaptures:
Expand Down Expand Up @@ -106,7 +83,7 @@ describe 'Code block generator', ->
pattern: 'c(pp|\\+\\+)', type: 'source', code: 'cpp'
]
codeBlocks = generator.makeAsciidocBlocks(languages)
expect(codeBlocks).toHaveLength 4 # Number of blocks
expect(codeBlocks).toHaveLength 3 # Number of blocks
expect(codeBlocks[0]).toEqualJson
begin: '^\\[(source),\\p{Blank}*(?i:(c(pp|\\+\\+)))(?:,([^\]]*))?\\]$'
beginCaptures:
Expand Down

0 comments on commit 42989ec

Please sign in to comment.