markdownr 0.5.7 → 0.5.9

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: e9a74b1e181f0fd5361c73e64a6e00659451cf075e1e41ec4f45c0cee9167e9d
4
- data.tar.gz: 44b5d07121159a9efadac6ee85bd4528d2490ec419b0752dbe15e1336e94eea2
3
+ metadata.gz: 84700eb63ad3d72b16419ce7e3d1df58fd543e20b28db82197bd65336e1ae5d9
4
+ data.tar.gz: 6043776aefb91dcc08d280fec07cd06b9f2f2a4061c380ec7a856d37838b312a
5
5
  SHA512:
6
- metadata.gz: 866416e07423170e5ec3c84e60da99682bfabb07b09cf1eb74f29e7e74f509c9982ec292641721ec0d054f5361bd6012fc00a34755ab46987c4462e63569926e
7
- data.tar.gz: 1a18c15a57094d2a5d72670d760d82d1eeca80ab1c694cc550a7ff69e352c6dd9e889840e515b0a40c9e59a9b48e9aa85744d6983f37f33c572b90cdd39c28a8
6
+ metadata.gz: cdd4ccae742493f6bf4d8e8960e22b91e984ad2aa9954c89131a9bb98d22af6d5e6181177b7e29764b86f0267f42624c2df19ce8e7477e9bfe6c0620a1d41144
7
+ data.tar.gz: c1984de4fb7097acf566bdb530d287e4e500ff151525773a6b258014d35582eb83269573c47882cb0fe232ab56fcde83c588fe50377b3e7782827a94fc895f95
@@ -636,8 +636,10 @@ module MarkdownServer
636
636
  inflections.sort_by! { |i| -i[:freq] }
637
637
  if inflections.any?
638
638
  rows = inflections.map { |i|
639
- link = i[:href] ? %(<a href="#{h(i[:href])}" target="_blank" rel="noopener">#{h(i[:word])}</a>) : h(i[:word])
640
- %(<tr><td>#{link}</td><td class="blb-right">#{i[:freq]}x</td></tr>)
639
+ match = i[:word] == word
640
+ cls = match ? ' class="blb-match"' : ""
641
+ link = i[:href] ? %(<a href="#{h(i[:href])}" target="_blank" rel="noopener">#{h(i[:word])}</a>) : h(i[:word])
642
+ %(<tr><td#{cls}>#{link}</td><td class="blb-right">#{i[:freq]}x</td></tr>)
641
643
  }.join
642
644
  infl_html = %(<h4 class="blb-heading">Inflections</h4>) +
643
645
  %(<table class="blb-table"><thead><tr><th class="blb-th">Form</th>) +
@@ -672,23 +674,35 @@ module MarkdownServer
672
674
  raw_html.gsub!(/<img[^>]*>/, "")
673
675
  raw_html.gsub!(/<a[^>]*class="hide-for-tablet"[^>]*>[\s\S]*?<\/a>/im, "")
674
676
  raw_html.gsub!(/<span[^>]*class="hide-for-tablet"[^>]*>[\s\S]*?<\/span>/im, "")
677
+ # Use control-char placeholders so blb-match survives the tag-strip pass
675
678
  verse_html = raw_html.gsub(/<span\s[^>]*class="word-phrase"[^>]*>([\s\S]*?)<\/span>/im) do
676
679
  inner = $1
677
680
  word = inner.sub(/<sup[\s\S]*/im, "").gsub(/<[^>]+>/, "")
678
681
  .gsub(/&nbsp;/i, " ").strip
679
682
  inner.match?(/<sup[^>]*class="[^"]*strongs criteria[^"]*"/i) ?
680
- %(<span class="blb-match">#{h(word)}</span>) : h(word)
683
+ "\x02#{word}\x03" : word
684
+ end
685
+ # Fallback for translations without word-phrase spans (NASB, ESV, etc.)
686
+ # The criteria word appears directly before its <sup class="strongs criteria"> tag
687
+ unless verse_html.include?("\x02")
688
+ verse_html.gsub!(/([\w]+[,;:.!?'"]*)\s*<sup[^>]*class="[^"]*strongs criteria[^"]*"[\s\S]*?<\/sup>/im) do
689
+ "\x02#{$1}\x03"
690
+ end
681
691
  end
682
692
  verse_html.gsub!(/<sup[^>]*>[\s\S]*?<\/sup>/im, "")
683
693
  verse_html.gsub!(/<[^>]+>/, "")
684
694
  verse_html.gsub!(/&nbsp;/i, " ")
685
695
  verse_html.gsub!(/&#(\d+);/) { [$1.to_i].pack("U") rescue " " }
686
696
  verse_html.gsub!(/&#x([\da-f]+);/i) { [$1.to_i(16)].pack("U") rescue " " }
687
- verse_html.gsub!(/&amp;/, "&").gsub!(/&lt;/, "<").gsub!(/&gt;/, ">")
697
+ verse_html.gsub!(/&amp;/, "&")
698
+ verse_html.gsub!(/&lt;/, "<")
699
+ verse_html.gsub!(/&gt;/, ">")
688
700
  verse_html.gsub!(/\s+/, " ")
689
701
  verse_html.strip!
690
702
  # Strip the mobile citation prefix ("Mat 5:17 - ") left by hide-for-tablet removal
691
703
  verse_html.sub!(/\A#{Regexp.escape(cite)}\s*-\s*/i, "")
704
+ # Restore match placeholders as highlighted spans
705
+ verse_html.gsub!(/\x02([^\x03]*)\x03/) { %(<span class="blb-match">#{h($1.strip)}</span>) }
692
706
 
693
707
  next if cite.empty? || verse_html.empty?
694
708
  full_href = cite_href.empty? ? nil : (cite_href.start_with?("http") ? cite_href : base + cite_href)
@@ -749,6 +763,98 @@ module MarkdownServer
749
763
  end
750
764
  end
751
765
 
766
+ get "/debug/raw-fetch" do
767
+ url = params[:url].to_s.strip
768
+ halt 400, "missing ?url=" if url.empty?
769
+ html = fetch_external_page(url)
770
+ halt 502, "fetch failed" unless html
771
+ content_type :text
772
+ # Show processing steps for first verse
773
+ chunk = html.split(/<div\s[^>]*id="bVerse_\d+"[^>]*>/).drop(1).first
774
+ return "no bVerse chunks found" unless chunk
775
+
776
+ cite = chunk[/tablet-order-2[^>]*>[\s\S]{0,400}?<a[^>]*>(.*?)<\/a>/im, 1]
777
+ &.gsub(/<[^>]+>/, "")&.strip || "?"
778
+ raw_html = chunk[/class="EngBibleText[^"]*"[^>]*>([\s\S]*?)<\/div>/im, 1] || "(no EngBibleText found)"
779
+
780
+ lines = ["=== cite: #{cite} ===",
781
+ "=== EngBibleText raw (#{raw_html.length} chars) ===",
782
+ raw_html, ""]
783
+
784
+ # Simulate the processing steps
785
+ rh = raw_html.dup
786
+ rh.gsub!(/<img[^>]*>/, "")
787
+ rh.gsub!(/<a[^>]*class="hide-for-tablet"[^>]*>[\s\S]*?<\/a>/im, "")
788
+ rh.gsub!(/<span[^>]*class="hide-for-tablet"[^>]*>[\s\S]*?<\/span>/im, "")
789
+
790
+ wp_matches = rh.scan(/<span\s[^>]*class="word-phrase"[^>]*>([\s\S]*?)<\/span>/im)
791
+ lines << "=== word-phrase matches (#{wp_matches.length}) ==="
792
+ wp_matches.each_with_index do |(inner), i|
793
+ is_criteria = inner.match?(/<sup[^>]*class="[^"]*strongs criteria[^"]*"/i)
794
+ word = inner.sub(/<sup[\s\S]*/im, "").gsub(/<[^>]+>/, "").gsub(/&nbsp;/i, " ").strip
795
+ lines << " [#{i}] criteria=#{is_criteria} word=#{word.inspect}"
796
+ end
797
+
798
+ # Now simulate the full processing pipeline
799
+ verse_html = rh.gsub(/<span\s[^>]*class="word-phrase"[^>]*>([\s\S]*?)<\/span>/im) do
800
+ inner = $1
801
+ word = inner.sub(/<sup[\s\S]*/im, "").gsub(/<[^>]+>/, "").gsub(/&nbsp;/i, " ").strip
802
+ inner.match?(/<sup[^>]*class="[^"]*strongs criteria[^"]*"/i) ? "\x02#{word}\x03" : word
803
+ end
804
+ lines << "\n=== after word-phrase gsub (placeholder check) ==="
805
+ lines << " contains \\x02: #{verse_html.include?("\x02")}"
806
+ lines << " contains \\x03: #{verse_html.include?("\x03")}"
807
+ ph = verse_html[/\x02[^\x03]*\x03/]
808
+ lines << " placeholder found: #{ph.inspect}"
809
+
810
+ verse_html.gsub!(/<sup[^>]*>[\s\S]*?<\/sup>/im, "")
811
+ verse_html.gsub!(/<[^>]+>/, "")
812
+ verse_html.gsub!(/&nbsp;/i, " ")
813
+ verse_html.gsub!(/&#(\d+);/) { [$1.to_i].pack("U") rescue " " }
814
+ verse_html.gsub!(/&#x([\da-f]+);/i) { [$1.to_i(16)].pack("U") rescue " " }
815
+ verse_html.gsub!(/&amp;/, "&")
816
+ verse_html.gsub!(/&lt;/, "<")
817
+ verse_html.gsub!(/&gt;/, ">")
818
+ verse_html.gsub!(/\s+/, " ")
819
+ verse_html.strip!
820
+
821
+ lines << "=== after tag-strip (placeholder check) ==="
822
+ lines << " contains \\x02: #{verse_html.include?("\x02")}"
823
+ ph2 = verse_html[/\x02[^\x03]*\x03/]
824
+ lines << " placeholder found: #{ph2.inspect}"
825
+ lines << " verse_html snippet: #{verse_html[0, 200].inspect}"
826
+
827
+ # Apply the final restore
828
+ restored = verse_html.gsub(/\x02([^\x03]*)\x03/) { "<span class=\"blb-match\">#{$1.strip}</span>" }
829
+ lines << "\n=== after placeholder restore ==="
830
+ lines << " restored snippet: #{restored[0, 300].inspect}"
831
+
832
+ # Now compare with actual blueletterbible_html output
833
+ full_output = blueletterbible_html(html, url)
834
+ conc_match = full_output[/blb-match[^<]*<\/span>/]
835
+ lines << "\n=== blueletterbible_html output (blb-match check) ==="
836
+ lines << " contains blb-match: #{full_output.include?("blb-match")}"
837
+ lines << " blb-match context: #{conc_match.inspect}"
838
+ # Show the concordance section
839
+ conc_start = full_output.index("blb-heading") ? full_output.rindex("<h4", full_output.index("Concordance") || 0) : nil
840
+ if conc_start
841
+ lines << " concordance html (first 500 chars): #{full_output[conc_start, 500].inspect}"
842
+ end
843
+
844
+ lines.join("\n")
845
+ end
846
+
847
+ get "/debug/fetch" do
848
+ url = params[:url].to_s.strip
849
+ halt 400, "missing ?url=" if url.empty?
850
+ html = fetch_external_page(url)
851
+ halt 502, "fetch failed" unless html
852
+ content_type :html
853
+ rendered = url.match?(/blueletterbible\.org\/lexicon\//i) ? blueletterbible_html(html, url) : page_html(html, url)
854
+ blb_css = "<style>.blb-table{width:100%;border-collapse:collapse;font-size:.85rem;margin-bottom:.6rem}.blb-table th,.blb-table td{padding:3px 7px;border:1px solid #ddd}.blb-th{text-align:left;font-weight:normal;background:#f5f0e4;color:#555;width:38%}.blb-right{text-align:right}.blb-nowrap{white-space:nowrap;vertical-align:top}.blb-match{color:#b33!important;font-weight:700!important;font-style:italic!important}.blb-heading{font-size:.82rem;font-weight:600;margin:.7rem 0 .25rem;color:#555;text-transform:uppercase;letter-spacing:.04em}.blb-usage{font-size:.85rem}.blb-usage ol{margin:.1rem 0 .1rem 1.3rem;padding:0;list-style-type:decimal}.blb-usage ol ol{list-style-type:lower-alpha}.blb-usage li{margin-bottom:.15rem}</style>"
855
+ "<html><head>#{blb_css}</head><body style='font-family:sans-serif;max-width:800px;margin:2rem auto;padding:0 1rem'>#{rendered}</body></html>"
856
+ end
857
+
752
858
  get "/download/*" do
753
859
  requested = params["splat"].first.to_s
754
860
  real_path = safe_path(requested)
@@ -1,3 +1,3 @@
1
1
  module MarkdownServer
2
- VERSION = "0.5.7"
2
+ VERSION = "0.5.9"
3
3
  end
data/views/layout.erb CHANGED
@@ -319,10 +319,12 @@
319
319
  a.wiki-link {
320
320
  color: #6a8e3e;
321
321
  border-bottom: 1px dashed #6a8e3e;
322
+ margin: 0 0.2rem;
322
323
  }
323
324
  span.wiki-link.broken {
324
325
  color: #c44;
325
326
  border-bottom: 1px dashed #c44;
327
+ margin: 0 0.2rem;
326
328
  }
327
329
 
328
330
  /* Raw/code view */
@@ -915,7 +917,7 @@
915
917
  .blb-th { text-align: left; font-weight: normal; background: #f5f0e4; color: #555; width: 38%; }
916
918
  .blb-right { text-align: right; }
917
919
  .blb-nowrap { white-space: nowrap; vertical-align: top; }
918
- .blb-match { color: #b33; font-weight: 600; }
920
+ .blb-match { color: #b33 !important; font-weight: 700 !important; font-style: italic !important; }
919
921
  .blb-heading { font-size: 0.82rem; font-weight: 600; margin: 0.7rem 0 0.25rem; color: #555; text-transform: uppercase; letter-spacing: 0.04em; }
920
922
  .blb-usage { font-size: 0.85rem; }
921
923
  .blb-usage ol { margin: 0.1rem 0 0.1rem 1.3rem; padding: 0; list-style-type: decimal; }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdownr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Dunn