kramdown-man 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d53e0152c21c6a0e3e32b4f2dc2d185577eb01f34cd9cbfb8a300e5077e6648
4
- data.tar.gz: c825469b0addc74ff69b1d1b53c54021d7020e9ae7284b94913187d58a61e6a9
3
+ metadata.gz: 30fd9e9769c09ef4d6220ce37ee0a810624e996983ab83151f75c35aa573f420
4
+ data.tar.gz: ab547ca91944b0d38ef7c826a61c69d99a727541793691a2e936595a3c75f039
5
5
  SHA512:
6
- metadata.gz: fa320fdff23430cb680ad6aadae1b52a79a9eb78bd42ab58b802460c23892f0597a3b536744ffc40584c3309c441a6f8671a37ba9a149653f7ff27ced654f90d
7
- data.tar.gz: 69465385b9ec09efcbe01ccb45c014c47dc04485687682167a68dc0f700e3009a34080d0048ffbc3612991fee9dc16f7445dca7078ab52c0c35860ec798a9f89
6
+ metadata.gz: b2056c28f02cd6ce02a06e21872fa95c22963420ef7e5583f99af92d46767c5d57d23afa187c6587aa1077ee0f6871a54ed6e02e295bba1c7244333c4bbbf451
7
+ data.tar.gz: 64cb91e4c0c77aed3fca7dedf6d925cd81e35a6ad6b3acd721363b9391a18c8e0460655e88b094bf58b9ed7b85f04eb6f180eb96f89f2d5ca328f515dd2f3c51
data/ChangeLog.md CHANGED
@@ -1,3 +1,14 @@
1
+ ### 1.0.1 / 2023-12-05
2
+
3
+ * Treat markdown code-fence `kd:codespan`s the same as `kd:codeblock`s.
4
+
5
+ ```
6
+ puts "hello world"
7
+ ```
8
+ ```
9
+ puts "hello world"
10
+ ```
11
+
1
12
  ### 1.0.0 / 2023-12-03
2
13
 
3
14
  * Ignore `kd:blank` elements to reduce size of generated man pages.
data/README.md CHANGED
@@ -6,11 +6,12 @@
6
6
 
7
7
  * [Homepage](https://github.com/postmodern/kramdown-man#readme)
8
8
  * [Issues](https://github.com/postmodern/kramdown-man/issues)
9
- * [Documentation](http://rubydoc.info/gems/kramdown-man/frames)
9
+ * [Documentation](https://rubydoc.info/gems/kramdown-man)
10
10
 
11
11
  ## Description
12
12
 
13
- A [Kramdown][kramdown] convert for converting Markdown files into man pages.
13
+ Allows you to write man pages for commands in pure Markdown and convert them to
14
+ roff using [Kramdown][kramdown].
14
15
 
15
16
  ## Features
16
17
 
@@ -22,7 +23,9 @@ A [Kramdown][kramdown] convert for converting Markdown files into man pages.
22
23
  * Supports multi-paragraph list items and blockquotes.
23
24
  * Supports converting `[foo-bar](foo-bar.1.md)` and `[bash](man:bash(1))`
24
25
  links into `SEE ALSO` man page references.
25
- * Provides Rake task for converting `man/*.md` into man pages.
26
+ * Provides a handy `kramdown-man` command for converting or previewing
27
+ markdown man pages.
28
+ * Provides a rake task for converting `man/*.md` into man pages.
26
29
  * Uses the pure-Ruby [Kramdown][kramdown] markdown parser.
27
30
  * Supports [Ruby] 3.x, [JRuby], and [TruffleRuby].
28
31
 
@@ -65,6 +68,8 @@ File.write('man/kramdown-man.1',doc.to_man)
65
68
  system 'man', 'man/kramdown-man.1'
66
69
  ```
67
70
 
71
+ ### Rake Task
72
+
68
73
  Define a `man` and file tasks which render all `*.md` files within the
69
74
  `man/` directory:
70
75
 
@@ -73,6 +78,12 @@ require 'kramdown/man/task'
73
78
  Kramdown::Man::Task.new
74
79
  ```
75
80
 
81
+ Then you can generate man pages for all `*.md` in the `man/` directory:
82
+
83
+ ```shell
84
+ $ rake man
85
+ ```
86
+
76
87
  ## Syntax
77
88
 
78
89
  ### Code
@@ -226,8 +237,6 @@ ex·am·ple
226
237
  ### Code Blocks
227
238
 
228
239
  ```markdown
229
- Source code:
230
-
231
240
  #include <stdio.h>
232
241
 
233
242
  int main()
@@ -235,11 +244,8 @@ Source code:
235
244
  printf("hello world\n");
236
245
  return 0;
237
246
  }
238
-
239
247
  ```
240
248
 
241
- Source code:
242
-
243
249
  #include <stdio.h>
244
250
 
245
251
  int main()
@@ -248,6 +254,16 @@ Source code:
248
254
  return 0;
249
255
  }
250
256
 
257
+ #### Code Fences
258
+
259
+ ```
260
+ puts "hello world"
261
+ ```
262
+
263
+ ```
264
+ puts "hello world"
265
+ ```
266
+
251
267
  ## Requirements
252
268
 
253
269
  * [kramdown] ~> 2.0
@@ -260,7 +276,7 @@ gem install kramdown-man
260
276
 
261
277
  ## Alternatives
262
278
 
263
- * [Redcarpet::Render::ManPage](http://rubydoc.info/gems/redcarpet/Redcarpet/Render/ManPage)
279
+ * [Redcarpet::Render::ManPage](https://rubydoc.info/gems/redcarpet/Redcarpet/Render/ManPage)
264
280
  * [ronn](https://github.com/rtomayko/ronn#readme)
265
281
  * [md2man](https://github.com/sunaku/md2man#readme)
266
282
 
@@ -270,9 +286,9 @@ Copyright (c) 2013-2023 Hal Brodigan
270
286
 
271
287
  See {file:LICENSE.txt} for details.
272
288
 
273
- [kramdown]: http://kramdown.gettalong.org/
274
- [roff]: http://en.wikipedia.org/wiki/Roff
289
+ [kramdown]: https://kramdown.gettalong.org/
290
+ [roff]: https://en.wikipedia.org/wiki/Roff_(software)
275
291
 
276
- [Ruby]: http://www.ruby-lang.org/
277
- [JRuby]: http://jruby.org/
292
+ [Ruby]: https://www.ruby-lang.org/
293
+ [JRuby]: https://jruby.org/
278
294
  [TruffleRuby]: https://github.com/oracle/truffleruby#readme
data/gemspec.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  name: kramdown-man
2
- summary: Converts markdown to man pages
3
- description: A Kramdown converter for converting Markdown files into man pages.
2
+ summary: Allows you to write man pages in pure markdown.
3
+ description: |
4
+ Allows you to write man pages for commands in pure Markdown and convert them
5
+ to roff using Kramdown.
6
+
4
7
  license: MIT
5
8
  authors: Postmodern
6
9
  email: postmodern.mod3@gmail.com
@@ -901,7 +901,22 @@ module Kramdown
901
901
  # The roff output.
902
902
  #
903
903
  def convert_codespan(codespan)
904
- "\\fB#{codespan.value}\\fR"
904
+ # ``` code fence blocks are parsed as kd:codespans
905
+ if codespan.options[:codespan_delimiter] == '```'
906
+ # ignore the first and last newlines
907
+ contents = escape(codespan.value[1..-2])
908
+
909
+ <<~ROFF
910
+ .PP
911
+ .RS 4
912
+ .EX
913
+ #{contents}
914
+ .EE
915
+ .RE
916
+ ROFF
917
+ else
918
+ "\\fB#{escape(codespan.value)}\\fR"
919
+ end
905
920
  end
906
921
 
907
922
  #
@@ -3,6 +3,6 @@
3
3
  module Kramdown
4
4
  module Man
5
5
  # kramdown-man version
6
- VERSION = "1.0.0"
6
+ VERSION = "1.0.1"
7
7
  end
8
8
  end
data/man/kramdown-man.1 CHANGED
@@ -1,9 +1,12 @@
1
1
  .\" Generated by kramdown-man 1.0.0
2
2
  .\" https://github.com/postmodern/kramdown-man#readme
3
3
  .TH kramdown-man 1 "April 2013" kramdown-man "User Manuals"
4
+ .SH NAME
5
+ .PP
6
+ kramdown\-man \- generates man pages from markdown files
4
7
  .SH SYNOPSIS
5
8
  .PP
6
- \fBkramdown-man\fR \[lB]\fIoptions\fP\[rB] \fIMARKDOWN\[ru]FILE\fP
9
+ \fBkramdown\-man\fR \[lB]\fIoptions\fP\[rB] \fIMARKDOWN\[ru]FILE\fP
7
10
  .SH DESCRIPTION
8
11
  .PP
9
12
  A Kramdown
@@ -16,14 +19,14 @@ plugin for converting Markdown files into man pages\.
16
19
  The input markdown file to convert\.
17
20
  .SH OPTIONS
18
21
  .TP
19
- \fB-o\fR, \fB--output\fR \fIOUTPUT\fP
22
+ \fB\-o\fR, \fB\-\-output\fR \fIOUTPUT\fP
20
23
  The file to write the man page output to\.
21
24
  .TP
22
- \fB-V\fR, \fB--version\fR
23
- Prints the \fBkramdown-man\fR version\.
25
+ \fB\-V\fR, \fB\-\-version\fR
26
+ Prints the \fBkramdown\-man\fR version\.
24
27
  .TP
25
- \fB-h\fR, \fB--help\fR
26
- Prints the usage for \fBkramdown-man\fR\.
28
+ \fB\-h\fR, \fB\-\-help\fR
29
+ Prints the usage for \fBkramdown\-man\fR\.
27
30
  .SH EXAMPLE
28
31
  .PP
29
32
  Render a man page from markdown:
@@ -55,8 +58,8 @@ system \(aqman\(aq, \(aqman\[sl]kramdown\-man\.1\(aq
55
58
  .RE
56
59
  .SS RAKE TASK
57
60
  .PP
58
- Define a \fBman\fR and files tasks which render all \fB*.md\fR files within the
59
- \fBman/\fR directory:
61
+ Define a \fBman\fR and files tasks which render all \fB*\.md\fR files within the
62
+ \fBman\[sl]\fR directory:
60
63
  .PP
61
64
  .RS 4
62
65
  .EX
@@ -109,7 +112,7 @@ Normal paragraph\.
109
112
  .EE
110
113
  .RE
111
114
  .PP
112
- \fBcommand\fR \[lB]\fB--foo\fR\[rB] \fBFILE\fP
115
+ \fBcommand\fR \[lB]\fB\-\-foo\fR\[rB] \fBFILE\fP
113
116
  .SS Argument Definitions
114
117
  .PP
115
118
  .RS 4
@@ -130,7 +133,7 @@ Description here\.
130
133
  .EE
131
134
  .RE
132
135
  .TP
133
- \fB-o\fR, \fB--option\fR \fIVALUE\fP
136
+ \fB\-o\fR, \fB\-\-option\fR \fIVALUE\fP
134
137
  Description here\.
135
138
  .SS Links
136
139
  .PP
@@ -253,8 +256,6 @@ Perfection is achieved, not when there is nothing more to add, but when there is
253
256
  .PP
254
257
  .RS 4
255
258
  .EX
256
- Source code:
257
-
258
259
  \[sh]include <stdio\.h>
259
260
 
260
261
  int main()
@@ -262,13 +263,7 @@ Source code:
262
263
  printf(\[dq]hello world\en\[dq]);
263
264
  return 0;
264
265
  \[rC]
265
- .EE
266
- .RE
267
- .PP
268
- Source code:
269
- .PP
270
- .RS 4
271
- .EX
266
+
272
267
  \[sh]include <stdio\.h>
273
268
 
274
269
  int main()
@@ -278,6 +273,22 @@ int main()
278
273
  \[rC]
279
274
  .EE
280
275
  .RE
276
+ .SS Code Fences
277
+ .PP
278
+ .RS 4
279
+ .EX
280
+ \`\`\`
281
+ puts \[dq]hello world\[dq]
282
+ \`\`\`
283
+ .EE
284
+ .RE
285
+ .PP
286
+ .PP
287
+ .RS 4
288
+ .EX
289
+ puts \[dq]hello world\[dq]
290
+ .EE
291
+ .RE
281
292
  .SH AUTHOR
282
293
  .PP
283
294
  Postmodern
@@ -1,5 +1,9 @@
1
1
  # kramdown-man 1 "April 2013" kramdown-man "User Manuals"
2
2
 
3
+ ## NAME
4
+
5
+ kramdown-man - generates man pages from markdown files
6
+
3
7
  ## SYNOPSIS
4
8
 
5
9
  `kramdown-man` [*options*] *MARKDOWN_FILE*
@@ -175,8 +179,6 @@ ex·am·ple
175
179
 
176
180
  ### Code Blocks
177
181
 
178
- Source code:
179
-
180
182
  #include <stdio.h>
181
183
 
182
184
  int main()
@@ -185,8 +187,6 @@ ex·am·ple
185
187
  return 0;
186
188
  }
187
189
 
188
- Source code:
189
-
190
190
  #include <stdio.h>
191
191
 
192
192
  int main()
@@ -195,6 +195,16 @@ Source code:
195
195
  return 0;
196
196
  }
197
197
 
198
+ #### Code Fences
199
+
200
+ ```
201
+ puts "hello world"
202
+ ```
203
+
204
+ ```
205
+ puts "hello world"
206
+ ```
207
+
198
208
  ## AUTHOR
199
209
 
200
210
  Postmodern <postmodern.mod3@gmail.com>
data/spec/cli_spec.rb CHANGED
@@ -116,6 +116,11 @@ Please report the following text to: #{Regexp.escape(described_class::BUG_REPORT
116
116
  let(:markdown_file) { File.join(man_dir,'kramdown-man.1.md') }
117
117
 
118
118
  describe "#run" do
119
+ let(:version) { Kramdown::Man::VERSION }
120
+ let(:man_page_regex) do
121
+ /\A.\\" Generated by kramdown-man #{Regexp.escape(version)}\n/
122
+ end
123
+
119
124
  context "when given a markdown file" do
120
125
  let(:argv) { [markdown_file] }
121
126
 
@@ -129,7 +134,7 @@ Please report the following text to: #{Regexp.escape(described_class::BUG_REPORT
129
134
  it "must write the man page output to the output file" do
130
135
  subject.run(markdown_file)
131
136
 
132
- expect(File.read(output)).to match(/\A.\\" Generated by kramdown-man 1.0.0\n/)
137
+ expect(File.read(output)).to match(man_page_regex)
133
138
  end
134
139
  end
135
140
 
@@ -148,7 +153,7 @@ Please report the following text to: #{Regexp.escape(described_class::BUG_REPORT
148
153
  it "must print the man page to stdout" do
149
154
  expect {
150
155
  subject.run(argv)
151
- }.to output(/\A.\\" Generated by kramdown-man 1.0.0\n/).to_stdout
156
+ }.to output(man_page_regex).to_stdout
152
157
  end
153
158
  end
154
159
 
@@ -708,13 +708,37 @@ describe Kramdown::Man::Converter do
708
708
  end
709
709
 
710
710
  describe "#convert_codespan" do
711
- let(:code) { "puts 'hello world'" }
712
- let(:markdown) { "`#{code}`" }
711
+ let(:code) { "puts 'hello world'" }
712
+ let(:escaped_code) { 'puts \(aqhello world\(aq' }
713
+ let(:markdown) { "`#{code}`" }
713
714
 
714
715
  let(:codespan) { doc.root.children[0].children[0] }
715
716
 
716
717
  it "should convert codespan elements into '\\fBcode\\fR'" do
717
- expect(subject.convert_codespan(codespan)).to eq("\\fB#{code}\\fR")
718
+ expect(subject.convert_codespan(codespan)).to eq("\\fB#{escaped_code}\\fR")
719
+ end
720
+
721
+ context "when given a ``` codespan" do
722
+ let(:markdown) do
723
+ <<~MARKDOWN
724
+ ```
725
+ #{code}
726
+ ```
727
+ MARKDOWN
728
+ end
729
+
730
+ it "must treat the codespan element as a codeblock" do
731
+ expect(subject.convert_codespan(codespan)).to eq(
732
+ <<~ROFF
733
+ .PP
734
+ .RS 4
735
+ .EX
736
+ #{escaped_code}
737
+ .EE
738
+ .RE
739
+ ROFF
740
+ )
741
+ end
718
742
  end
719
743
  end
720
744
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown-man
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-04 00:00:00.000000000 Z
11
+ date: 2023-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -38,7 +38,9 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
- description: A Kramdown converter for converting Markdown files into man pages.
41
+ description: |
42
+ Allows you to write man pages for commands in pure Markdown and convert them
43
+ to roff using Kramdown.
42
44
  email: postmodern.mod3@gmail.com
43
45
  executables:
44
46
  - kramdown-man
@@ -100,5 +102,5 @@ requirements: []
100
102
  rubygems_version: 3.4.10
101
103
  signing_key:
102
104
  specification_version: 4
103
- summary: Converts markdown to man pages
105
+ summary: Allows you to write man pages in pure markdown.
104
106
  test_files: []