Re: [Rfc-markdown] SVG diagrams for slides

Carsten Bormann <cabo@tzi.org> Sun, 24 July 2022 01:44 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: rfc-markdown@ietfa.amsl.com
Delivered-To: rfc-markdown@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 760BDC157901 for <rfc-markdown@ietfa.amsl.com>; Sat, 23 Jul 2022 18:44:20 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.909
X-Spam-Level:
X-Spam-Status: No, score=-1.909 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9syf-NbEzzMP for <rfc-markdown@ietfa.amsl.com>; Sat, 23 Jul 2022 18:44:18 -0700 (PDT)
Received: from gabriel-smtp.zfn.uni-bremen.de (gabriel-smtp.zfn.uni-bremen.de [IPv6:2001:638:708:32::15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1FACBC14792F for <rfc-markdown@ietf.org>; Sat, 23 Jul 2022 18:44:16 -0700 (PDT)
Received: from smtpclient.apple (p5089ad4f.dip0.t-ipconnect.de [80.137.173.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-smtp.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4Lr5Z45J0mzDCbd; Sun, 24 Jul 2022 03:44:12 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <63259.1658625940@dooku>
Date: Sun, 24 Jul 2022 03:44:12 +0200
Cc: rfc-markdown@ietf.org
Content-Transfer-Encoding: quoted-printable
Message-Id: <2E0491A4-C4C2-456D-B566-17BC440ADE00@tzi.org>
References: <63259.1658625940@dooku>
To: Michael Richardson <mcr+ietf@sandelman.ca>
X-Mailer: Apple Mail (2.3696.100.31)
Archived-At: <https://mailarchive.ietf.org/arch/msg/rfc-markdown/NVQvWXUvWZVH16_Ms9UyuIsY0Y4>
Subject: Re: [Rfc-markdown] SVG diagrams for slides
X-BeenThere: rfc-markdown@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: "rfc-markdown is a discussion list for people writing I-Ds and RFCs in Markdown and the authors of the tools used for that." <rfc-markdown.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/rfc-markdown>, <mailto:rfc-markdown-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/rfc-markdown/>
List-Post: <mailto:rfc-markdown@ietf.org>
List-Help: <mailto:rfc-markdown-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/rfc-markdown>, <mailto:rfc-markdown-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 24 Jul 2022 01:44:20 -0000

Hi Michael,

On 24. Jul 2022, at 03:25, Michael Richardson <mcr+ietf@sandelman.ca> wrote:
> 
> 
> Is there an obvious way to get .SVG file out of kdrfc for each diagram that
> was up-converted from markdown?  Because SVG into a ODP/PDF/PPT makes more
> sense than raster.

What do you want to do?

> I can attempt to extract it out of the XML, but I feel that there should be a
> better way.

I’m pretty sure that running a small XPath snippet is the easiest way to do this.

Of course, you also can read the memoized results from REFCACHEDIR, but that structure is tied to a specific kramdown-rfc version and might change frequently (although it hasn’t for a while).  [I probably should write these out in CBOR and not in Ruby’s Marshal.dump…]

But XPath really is trivial, see below.

Grüße, Carsten


#!/usr/bin/env ruby
require 'rexml/document'

d = REXML::Document.new(ARGF)

REXML::XPath.each(d.root, "//svg:svg", {"svg" => "http://www.w3.org/2000/svg"}) do |x|
  puts x.to_s[0..200]
end