From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/15999 Path: news.gmane.org!.POSTED!not-for-mail From: Huub de Beer Newsgroups: gmane.text.pandoc Subject: Update to paru, the Ruby wrapper around pandoc and filters. Now with improved documentation! Date: Sun, 13 Nov 2016 00:26:13 +0100 Message-ID: <1727510.xgb4n7lJqd@study> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1478993202 3935 195.159.176.226 (12 Nov 2016 23:26:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 12 Nov 2016 23:26:42 +0000 (UTC) User-Agent: KMail/5.2.3 (Linux/4.8.0-27-generic; KDE/5.26.0; x86_64; ; ) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDNYZJUTQUGBBF6KT3AQKGQE26AVB2Y-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Nov 13 00:26:38 2016 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-wm0-f55.google.com ([74.125.82.55]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c5hga-0005sS-MH for gtp-pandoc-discuss@m.gmane.org; Sun, 13 Nov 2016 00:26:12 +0100 Original-Received: by mail-wm0-f55.google.com with SMTP id g23sf12021100wme.1 for ; Sat, 12 Nov 2016 15:26:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=sender:from:to:reply-to:subject:date:message-id:user-agent :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=F7ivzZpTMtUr8DilteOgTfEVGMVbEDx7sf7b8x+HNjA=; b=ITfuueiHXEIZHtP+uiOIRMm+n2EPzOhU5GPN+Dh9Hsf2QlP0h545AS+lX+K6odKYIl FxdTuKQYnqjsqvWnUgdcnjFULrsH2KTew/FgkCNp4io94rw4RyIQrxFN0HAsQHTxFqkk MqPjzZZNVzTRmkJq0O3NIB2dJmwure+H26HLAZEQGQdBWalo0SOWz69gtJTzmRcg3SVh cnrSfzyB13vvNE+sIb209urHWVMWU5EWp6s9Ip63k6hKI/UqkiEzijILPWQA/3o590VY 86Ddw532A9zpydqijsy2yFHkw0BZKkeqn3dzxrWGIsf93BmBo116REcM79AWkx6WMPHL IjbA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:reply-to:subject:date:message-id:user-agent:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=F7ivzZpTMtUr8DilteOgTfEVGMVbEDx7sf7b8x+HNjA=; b=kEtOe40BfsWV2rRslpgCUInrEiEA1dMEAFsR8J88lI1MxDUgfdVem85Rz94InwcbsK 2XWkuHD1iLFse1/iyeGg1DJ+NTbRB0dlkPVC+pgec4IES2XqlXPXpiIrFzEJMgUoDnJA yIAF2gEu68SLIHpy9hta7LFA47ZoKivOkO9DI24AqJbCo4GYluzdnPd6p0dhl6C9kYFr azpjHTvFiMr5KuRkW1sdCaUV0t3Z0ZAZSeuADsYv0l6juhJ2++n3xXwg0qUcMqox4Gjp P80mFzGus6YU82i+/+zWfpJ8YO7tQxQq0OdZAwzjGMasXYQtOskcnJ/f1ZPIS67toC7K IQdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=sender:x-gm-message-state:from:to:reply-to:subject:date:message-id :user-agent:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=F7ivzZpTMtUr8DilteOgTfEVGMVbEDx7sf7b8x+HNjA=; b=OO6oLrpjhpsa+VVMa+paF4INtT6ypkEXwQKRu1zlLu2mFYjFsBtLb3S0EQQSJJCbcU NTYjBWzvtnip2W8wjj7Z2r+9Tac0B2C9RoDKAyaGWT/fQQqTxmpKQOvfJWMz+9LMiq4/ +PoGVRxuKhk4MEbh1SP/UgSrvRtY4CGTlKn5kR2dy2xbNi0s1PV75nlh/tfMW4Og9F/7 C/1Nueo3XTnfDNqdMTvPqR3EHMdI/xJoxBDE1sQnmdfM4qpf4MF1Gw/xYVoDvGCun21g PJjt/dxtBB4b1Phc0QtD4Rl6st+HIrbEVXANTK4t273CI0RDq6yjph76YszuQJvIMnAg fZJg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ABUngvdxYN8mDOwGrCTkpcT0bb/e5JvOUXGFZCT4IQuF7qN5Fkw4gYtVZiMlyG08fE0wgg== X-Received: by 10.28.29.140 with SMTP id d134mr31831wmd.13.1478993176204; Sat, 12 Nov 2016 15:26:16 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.28.184.151 with SMTP id i145ls227798wmf.9.gmail; Sat, 12 Nov 2016 15:26:15 -0800 (PST) X-Received: by 10.28.146.204 with SMTP id u195mr309602wmd.23.1478993175458; Sat, 12 Nov 2016 15:26:15 -0800 (PST) Original-Received: from mail-wm0-x235.google.com (mail-wm0-x235.google.com. [2a00:1450:400c:c09::235]) by gmr-mx.google.com with ESMTPS id l130si1308987wmf.2.2016.11.12.15.26.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Nov 2016 15:26:15 -0800 (PST) Received-SPF: pass (google.com: domain of h.t.de.beer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:400c:c09::235 as permitted sender) client-ip=2a00:1450:400c:c09::235; Original-Received: by mail-wm0-x235.google.com with SMTP id g23so38798151wme.1 for ; Sat, 12 Nov 2016 15:26:15 -0800 (PST) X-Received: by 10.28.221.11 with SMTP id u11mr4407808wmg.123.1478993174986; Sat, 12 Nov 2016 15:26:14 -0800 (PST) Original-Received: from study.localnet ([145.132.75.159]) by smtp.gmail.com with ESMTPSA id o143sm20132708wmd.7.2016.11.12.15.26.14 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 12 Nov 2016 15:26:14 -0800 (PST) X-Original-Sender: H.T.de.Beer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com; spf=pass (google.com: domain of h.t.de.beer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:400c:c09::235 as permitted sender) smtp.mailfrom=h.t.de.beer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.org gmane.text.pandoc:15999 Archived-At: Dear all, today I released version 0.2.1 of paru, the ruby wrapper around pandoc and filters. This release is compatible with pandoc version >= 1.18 and contains also some small bug fixes. Furthermore, I have updated the documentation extensively. Automating the use of pandoc with Ruby or writing pandoc filters in Ruby was never easier! See https://heerdebeer.org/Software/markdown/paru/ for more information. To wet you appetite for writing pandoc filters in Ruby, I give two canonical examples here: 1. Inserting markdown files from within other markdown files: #!/usr/bin/env ruby require "paru/filter" Paru::Filter.run do with "Para" do |paragraph| if paragraph.inner_markdown.lines.length == 1 command, path = paragraph.inner_markdown.strip.split " " if command == "::paru::insert" markdown = File.read path.gsub(/\\_/, "_") paragraph.outer_markdown = markdown end end end end 2. Numbering chapters, sections, and figures in a markdown files: #!/usr/bin/env ruby require "paru/filter" current_chapter = 0 current_section = 0 current_figure = 0 Paru::Filter.run do with "Header" do |header| if header.level == 1 current_chapter += 1 current_figure = 0 current_section = 0 header.inner_markdown = "Chapter #{current_chapter}. #{header.inner_markdown}" end if header.level == 2 current_section += 1 header.inner_markdown = "#{current_chapter}.#{current_section} #{header.inner_markdown}" end end with "Header + Image" do |image| current_figure += 1 image.inner_markdown = "Figure #{current_chapter}.#{current_figure} #{image.inner_markdown}" end end The methods inner_markdown and outer_markdown are quite useful when writing filters. Combined with the power of selectors such as "+" (follows), writing a filter is quite straightforward, have fun with pandoc! with kind regards -- Huub de Beer