Skip to content

Convert HTML content to HAML using html2haml#2

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/update-html-to-haml-converter
Draft

Convert HTML content to HAML using html2haml#2
Copilot wants to merge 3 commits intomasterfrom
copilot/update-html-to-haml-converter

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 30, 2025

Converts all 20,384 HTML content files to HAML format using the html2haml tool referenced in the problem statement.

Changes

  • Conversion script (convert_to_haml.rb): Batch converts HTML to HAML with custom DTD handling for XHTML 1.1 + MathML + SVG doctypes
  • HAML files: 20,384 .haml files created alongside existing .html files
  • Documentation (README.md): Conversion process, technical details, and usage instructions

Technical Details

The nLab content uses a non-standard doctype that html2haml doesn't support out of the box:

# Monkey patch to handle complex XHTML doctypes
module Nokogiri::XML
  class DTD
    def to_haml(tabs, options)
      if external_id =~ /XHTML.*MathML.*SVG/
        "#{tabulate(tabs)}!!! XML\n#{tabulate(tabs)}!!! 1.1\n"
      else
        "#{tabulate(tabs)}!!!\n"
      end
    end
  end
end

Converts:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" ...>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Example</title>

To:

!!! XML
!!! 1.1
%html{:xmlns => "http://www.w3.org/1999/xhtml"}
  %head
    %title
      Example

All 20,384 files converted successfully with semantic equivalence preserved.

Original prompt

https://github.com/haml/html2haml


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 30, 2025 14:24
Co-authored-by: ewdlop <25368970+ewdlop@users.noreply.github.com>
Co-authored-by: ewdlop <25368970+ewdlop@users.noreply.github.com>
Copilot AI changed the title [WIP] Update html2haml converter for improved performance Convert HTML content to HAML using html2haml Dec 30, 2025
Copilot AI requested a review from ewdlop December 30, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants