rdoc-markdown 0.17.1 → 0.17.2

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: '09bb3098a38fdecae06518b91286f487fa4f547246a9ab62728037b9bc373d5b'
4
- data.tar.gz: '094af12517d5e15a103e2a93c9472219b7611d4c1246999c996192ce69b5d992'
3
+ metadata.gz: b8caf2553ce9d28bdd362ab86ee4ee7b18981e3da7254dd0e752de2471e70c69
4
+ data.tar.gz: c67f5d859ffe70426fde7cd058486c0ced84e9c5066a1340574b8342b458d6e0
5
5
  SHA512:
6
- metadata.gz: dcdfcc880975aed0d669ae3006f3b938b4799a3a90fe933f4972479c6edb50aa7a4fdca3c69fe617e45eb5305cf7a0f22eebef46fdc2b22206a971f97136217b
7
- data.tar.gz: 62bd6ec996d342011a9b57d216ef06ba574af710eeacc69a909d280fdcb29f15851aa492f2fc729599c5c5e820ade24b9bd8cc1edf31d748896a891eebd17ca2
6
+ metadata.gz: 716297af9880007fc262c1c207603c5ad77d1cface68a5e08c22c9523b4e48e2d1952559fa1909ddd5d6d8f20f3e4169c9688a409125146d1eeccfbaeb19499c
7
+ data.tar.gz: 28949178739a1d0539c5a9d45ef260513b18f929f95db6b3a02feed82b45a24fb2f7bd2fb19cc90ea2688a923e9ff8fd7c8be53e25ac851e7b5168a61f654fb4
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
 
4
4
  ## Unreleased
5
5
 
6
+
7
+ ## 0.17.2
8
+
9
+ - Remove spaces after headers
10
+ - Remove legacy anchor links
11
+ - Remove extra files that are not required (js, css and etc)
12
+
6
13
  ## 0.17.1
7
14
 
8
15
  - Don't include files with .tt extension
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rdoc-markdown (0.17.1)
4
+ rdoc-markdown (0.17.2)
5
5
  csv
6
6
  erb
7
7
  rdoc (>= 8.0)
@@ -224,7 +224,7 @@ class RDoc::Generator::Markdown
224
224
  out_file = Pathname.new("#{output_dir}/#{page_output_path(page)}")
225
225
  out_file.dirname.mkpath
226
226
 
227
- next FileUtils.cp(File.expand_path(page.absolute_name, @source_dir), out_file) if page.relative_name.end_with?(".md", ".markdown")
227
+ next FileUtils.cp(File.expand_path(page.absolute_name, @source_dir), out_file) if page.relative_name.match?(/\.(?:md|markdown)\z/i)
228
228
 
229
229
  content = markdownify(render_description(page))
230
230
  File.write(out_file, finalize_markdown(
@@ -250,7 +250,7 @@ class RDoc::Generator::Markdown
250
250
  # @return [String] Relative Markdown path.
251
251
  def page_output_path(page)
252
252
  source_path = normalize_input_path_for_output(page.relative_name)
253
- return source_path if page.relative_name.match?(/\.(?:md|markdown)\z/)
253
+ return source_path if page.relative_name.match?(/\.(?:md|markdown)\z/i)
254
254
 
255
255
  dirname = File.dirname(source_path)
256
256
  basename = "#{File.basename(source_path).tr(".", "_")}.md"
@@ -306,6 +306,13 @@ class RDoc::Generator::Markdown
306
306
  # - raise - Raise an error to let you know
307
307
 
308
308
  fragment = Nokogiri::HTML.fragment(input)
309
+ fragment.css("span.legacy-anchor[id]").select do |span|
310
+ span.next_element&.name == "h1" && span["id"].match?(/\A(?:class|module)-/)
311
+ end.each(&:remove)
312
+ fragment.css("span.legacy-anchor[id]").each do |span|
313
+ heading = span.next_element
314
+ heading.add_child(span) if heading&.name&.match?(/\Ah[1-6]\z/)
315
+ end
309
316
 
310
317
  fragment.css("pre").each do |pre|
311
318
  language = pre["class"].to_s[/\A(?!highlight\z)[A-Za-z][A-Za-z0-9_+-]*\z/]
@@ -357,9 +364,7 @@ class RDoc::Generator::Markdown
357
364
  unknown_tags: @markdown_unknown_tags
358
365
  ).dup
359
366
  anchor_aliases.each do |token, id|
360
- anchor = %(<a id="#{id}"></a>)
361
- md.gsub!("#{token}\n\n#", "#{anchor}\n#")
362
- md.gsub!(token, anchor)
367
+ md.gsub!(token, %(<a id="#{id}"></a>))
363
368
  end
364
369
 
365
370
  normalize_definition_list_code_blocks(md).rstrip
@@ -607,6 +612,7 @@ class RDoc::Generator::Markdown
607
612
  output = content.lines.map(&:rstrip).join("\n")
608
613
  output = normalize_internal_links(output, current_output_path: current_output_path)
609
614
  output = output.sub(/\n{3,}/, "\n\n")
615
+ output = output.gsub(/^(#+ .+)\n\n/, "\\1\n")
610
616
  "#{output}\n"
611
617
  end
612
618
 
@@ -711,7 +717,7 @@ class RDoc::Generator::Markdown
711
717
  # @return [String, nil] Resolved output path, or nil when unresolved.
712
718
  def resolve_output_path(path, current_dir)
713
719
  candidates = [path, path.delete_prefix("#{@root_path_segment}/")]
714
- candidates += candidates.map { |candidate| candidate.sub(/_(md|markdown)\.md\z/, '.\1') }
720
+ candidates += candidates.map { |candidate| candidate.sub(/_(md|markdown)\.md\z/i, '.\1') }
715
721
 
716
722
  candidates.each do |candidate|
717
723
  return candidate if @known_output_paths.include?(candidate)
@@ -761,7 +767,7 @@ class RDoc::Generator::Markdown
761
767
  end.sort
762
768
  @class_output_paths = @classes.to_h { |klass| [klass.full_name, output_path_for(klass)] }
763
769
  @pages = @store.all_files.select(&:text?).select(&:display?)
764
- .reject { |page| page.relative_name.end_with?(".tt") }
770
+ .select { |page| page.relative_name.match?(/\.(?:md|markdown|rdoc)\z/i) }
765
771
  .sort_by(&:base_name)
766
772
  @markdown_output_object_ids = (@classes + @pages).map(&:object_id)
767
773
  @known_output_paths = @class_output_paths.values
@@ -5,6 +5,6 @@ module Rdoc
5
5
  # @private
6
6
  module Markdown
7
7
  # @private
8
- VERSION = "0.17.1"
8
+ VERSION = "0.17.2"
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav (Stas) Katkov