Skip to content

Instantly share code, notes, and snippets.

View aethanyc's full-sized avatar

Ting-Yu Lin aethanyc

  • Portland, OR, USA
  • 05:26 (UTC -07:00)
View GitHub Profile
@aethanyc
aethanyc / frame-tree-column-span.txt
Last active October 17, 2018 18:14
Frame tree dump of column span
<div style="column-count:3;">
<div id="kid">
<div id="grandkid">
a
<div id="spanner" style="column-span: all">b</div>
c
</div>
</div>
</div>
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This code resolves the problem described in
http://xahlee.info/perl-python/python_construct_tree_from_edge.html
"""
import collections
(set-macro-character #\} (get-macro-character #\)))
(set-macro-character #\{
#'(lambda (stream char)
(declare (ignore char))
(let ((plist (read-delimited-list #\} stream))
(hash (gensym)))
`(let ((,hash (make-hash-table :test #'equal)))
,@(loop for (key value) on plist by #'cddr
collect `(setf (gethash ,key ,hash) ,value))