lmt 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,17 +10,45 @@ The first regular expression handles the detection of include directives. It re
10
10
  /^!\s+include\s+\[.*\]\((.*)\)\s*$/
11
11
  ```
12
12
 
13
+ ## The Block Expressions
14
+
15
+ These regular expression recognize if, elseif, else, and end directives. The first group contains the conditional for blocks that have a conditional..
16
+
17
+ ``` ruby if_expression
18
+ /^!\s+if\s+(.*)$/
19
+ ```
20
+
21
+ ``` ruby else_expression
22
+ /^!\s+else/
23
+ ```
24
+
25
+ ``` ruby elsif_expression
26
+ /^!\s+elsif\s+(.*)$/
27
+ ```
28
+
29
+ ``` ruby end_expression
30
+ /^!\s+end$/
31
+ ```
32
+
13
33
  ## The Code Block Expression
14
34
 
15
- The second regular expression is intended to note when whe enter or leave a code block. It detects markdown code fences and processes the special directives. It has four groups. The first identifies white space at the beginning of the line. The second detects the language. The third determines if this is a replacement. The fourth is the name of the block (if applicable).
35
+ This expression is intended to note when whe enter or leave a code block. It detects markdown code fences and processes the special directives. It has four groups. The first identifies white space at the beginning of the line. The second detects the language. The third determines if this is a replacement. The fourth is the name of the block (if applicable).
16
36
 
17
37
  ``` ruby code_block_expression
18
- /^([s]*)``` ?([\w]*) ?(=?)([-\w]*)?/
38
+ /^(\s*)``` ?([\w]*) ?(=?)([-\w]*)?/
39
+ ```
40
+
41
+ ## The Extension Expression
42
+
43
+ This expression identifies blocks of code which are to be executed. The first group identifies white space at the beginning of the line.
44
+
45
+ ``` ruby extension_expression
46
+ /^(\s*)``` ruby !/
19
47
  ```
20
48
 
21
49
  ## The Macro Substitution Expression
22
50
 
23
- The third expression identifies macro expansions surrounded with `⦅` and `⦆`. The first bit deals with making sure that the opening `⦅` isn't escaped. Then there is one group which contains the name of the macro combined and any filters which are being used.
51
+ This identifies macro expansions surrounded with `⦅` and `⦆`. The first bit deals with making sure that the opening `⦅` isn't escaped. Then there is one group which contains the name of the macro combined and any filters which are being used.
24
52
 
25
53
  ``` ruby macro_substitution_expression
26
54
  /(?<!\\)⦅ *([-\w | ]*) *⦆/
data/src/lmt/lmw.rb.lmd CHANGED
@@ -268,6 +268,7 @@ We will match the lines against the expressions and, when a match occurs, we wil
268
268
  def substitute_directives_and_headers(lines)
269
269
  include_expression = ⦅include_expression⦆
270
270
  code_block_expression = ⦅code_block_expression⦆
271
+ extension_block_expression = ⦅extension_expression⦆
271
272
  in_block = false
272
273
  block_name = ""
273
274
  lines.map do |line|
@@ -289,26 +290,32 @@ def substitute_directives_and_headers(lines)
289
290
  end
290
291
  ```
291
292
 
292
- #### The header for code blocks
293
+ #### The Header for Code Blocks
293
294
 
294
295
  Code blocks need to be headed appropriately as markdown parsing eats the code block name. Because of this we put it in a `h6` header. When the block is repeated, we add a `(part n)` to the end. We also should be adding links for the next and last version of this header.
295
296
 
296
297
  ``` ruby make_code_block_header
297
- white_space, language, replacement_mark, name =
298
- code_block_expression.match(line)[1..-1]
299
- human_name = name.gsub(/[-_]/, ' ').split(' ').map(&:capitalize).join(' ')
300
- replacing = if replacement_mark == "="
301
- " Replacing"
302
- else
303
- ""
304
- end
305
- header = if name != ""
306
- "#######{replacing} Code Block: #{human_name}\n\n"
298
+ if line =~ extension_block_expression
299
+ white_space = extension_block_expression.match(line)[1]
300
+ header = "###### Execute Extension Block\n\n"
301
+ [header, "#{white_space}``` ruby\n"]
307
302
  else
308
- "#######{replacing} Output Block\n\n"
303
+ white_space, language, replacement_mark, name =
304
+ code_block_expression.match(line)[1..-1]
305
+ human_name = name.gsub(/[-_]/, ' ').split(' ').map(&:capitalize).join(' ')
306
+ replacing = if replacement_mark == "="
307
+ " Replacing"
308
+ else
309
+ ""
310
+ end
311
+ header = if name != ""
312
+ "#######{replacing} Code Block: #{human_name}\n\n"
313
+ else
314
+ "#######{replacing} Output Block\n\n"
315
+ end
316
+ [header,
317
+ "#{white_space}``` #{language}\n"]
309
318
  end
310
- [header,
311
- "#{white_space}``` #{language}\n"]
312
319
  ```
313
320
 
314
321
  ### Replacing the Markdown Links
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lmt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marty Gentillon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-17 00:00:00.000000000 Z
11
+ date: 2019-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler