Skip to content

Commit

Permalink
Spacing adjustments of shortcode replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
mendezcode committed Oct 31, 2013
1 parent cf9d43c commit b523732
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/shortcode-parser.js
Expand Up @@ -73,7 +73,7 @@ function parseShortcode(name, buf, inline) {

return {
attr: attr,
content: buf
content: inline ? buf : buf.replace(/(^\n|\n$)/g, '')
}

}
Expand Down
10 changes: 5 additions & 5 deletions test/fixtures/output.txt
Expand Up @@ -8,13 +8,15 @@

# Block Level > Same Line

<!-- container opts: {} --> ... On the same line ... <!-- /container -->
<!-- container opts: {} -->
... On the same line, spacing is adjusted ...
<!-- /container -->

# Block Level > Multiple Lines

<!-- container opts: {"hello":"world","name":"John","age":30,"float":55.5,"slider":null,"boolean":true} -->

... On different lines ...
... On different lines, spacing is preserved ...

<!-- /container -->

Expand All @@ -38,9 +40,7 @@ pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui offi
[12345]
[some_shortcode] [/some_shortcode]

# Nested Block Levels Not Supported

<!-- container opts: {} --> Nested Block Level Shortcodes <!-- container opts: {} --><!-- /container --> Not <!-- /container --> Supported [/container]
#

Lorem ipsum dolor sit amet, <strong style="font-size: 10px; font-family: 'Inconsolata',sans-serif;">Hello World</strong> adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Expand Down
8 changes: 3 additions & 5 deletions test/fixtures/shortcodes.txt
Expand Up @@ -8,13 +8,13 @@

# Block Level > Same Line

[container] ... On the same line ... [/container]
[container] ... On the same line, spacing is adjusted ... [/container]

# Block Level > Multiple Lines

[container hello=world name=John age=30 float=55.5 slider=null boolean=true other=undefined]

... On different lines ...
... On different lines, spacing is preserved ...

[/container]

Expand All @@ -38,9 +38,7 @@ pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui offi
[12345]
[some_shortcode] [/some_shortcode]

# Nested Block Levels Not Supported

[container] Nested Block Level Shortcodes [container] Not [/container] Supported [/container]
#

Lorem ipsum dolor sit amet, [bold size=10px font="Inconsolata"]Hello World[/bold] adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Expand Down
2 changes: 1 addition & 1 deletion test/unit.js
Expand Up @@ -35,7 +35,7 @@ vows.describe("Shortcode Parser").addBatch({
});

shortcode.add('container', container = function(buf, opts) {
return util.format('<!-- container opts: %s -->%s<!-- /container -->', JSON.stringify(opts), buf);
return util.format('<!-- container opts: %s -->\n%s\n<!-- /container -->', JSON.stringify(opts), buf);
});

shortcode.add('params_test', params_test = function(buf, opts) {
Expand Down

0 comments on commit b523732

Please sign in to comment.