Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves #55 sort attribute entries in document header #63

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
resolves #55 sort attribute entries in document header
  • Loading branch information
mojavelinux committed Aug 18, 2018
commit 97a3d933f28973e2b5848fe3f7a9e2cc36106508
7 changes: 6 additions & 1 deletion lib/kramdown-asciidoc/writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ def empty?
end

def to_s
(@header.empty? ? @body : (@header + (@body.empty? ? [] : [''] + @body))).join LF
if @header.empty?
@body.join LF
else
attrs, others = @header.partition {|it| it.start_with? ':' }
(others + attrs.sort + (@body.empty? ? [] : [''] + @body)).join LF
end
end
end
end; end
6 changes: 6 additions & 0 deletions spec/scenarios/attributes/sorting.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
= Document Title
:bar: bar
:experimental:
:foo: foo

menu:Terminal[Quit]
3 changes: 3 additions & 0 deletions spec/scenarios/attributes/sorting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Document Title

**Terminal > Quit**
3 changes: 3 additions & 0 deletions spec/scenarios/attributes/sorting.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:attributes:
foo: 'foo'
bar: 'bar'
2 changes: 1 addition & 1 deletion spec/scenarios/heading/lazy_ids/auto-ids.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= Document Title
:idseparator: -
:idprefix:
:idseparator: -

== A Section

Expand Down