Skip to content

Instantly share code, notes, and snippets.

View skoji's full-sized avatar
:octocat:
Working from home

Satoshi KOJIMA skoji

:octocat:
Working from home
View GitHub Profile
@skoji
skoji / nora_custom_sample_1.rb
Last active August 29, 2015 13:57
NoraMark (http://github.com/skoji/noramark) customization sample
text =<<EOF
speak(Alice): Alice is speaking.
speak(Bob): and this is Bob.
EOF
document = NoraMark::Document.parse(text)
document.add_transformer(generator: :html) do
modify "speak" do
@node.name = 'p'
@node.prepend_child inline('span', @node.parameters[0], classes: ['speaker'])
# Markdown-ish heading with explicit setion boundary
---
lang: ja
title: test title
stylesheets: css/normalize.css, css/main.css
---
=: this is the first heading
@skoji
skoji / markup-change.md
Last active August 29, 2015 13:57
中間案も追加しました

基本方針

  • 字下げに意味がある記法は採用しない。(NoraMarkの基本的な方針)

現状

見出し

==: など

箇条書き

@skoji
skoji / mini_noramark.pegjs
Last active August 29, 2015 14:00
mini NoraMark parser definition for PEG.js
start
= Document
Document
= EmptyLine* blocks:Block* { return blocks.join("\n"); }
Block
= b:(ExplicitBlock / ParagraphGroup) EmptyLine*
{ return b; }
ExplicitBlockHead
start
= Document
Document
= l:TheLine LF d:Document { d.unshift(l); return d }
/ l:TheLine { return [l]; }
TheLine = DocumentLine / NotAllowedLine
NotAllowedLine = "not allowed" LF { return "not allowed but here."; }
DocumentLine
@skoji
skoji / sample-htmlbook.nora
Last active August 29, 2015 14:01
sample-htmlbook.nora
---
title: サンプル文書
generator: htmlbook
---
#(titlepage) サンプル文書
by Satoshi Kojima
#(preface) 前書き
@skoji
skoji / gist:9359b5f32876b8b32852
Last active August 29, 2015 14:04
デフォルト引数

rubyでメソッドの引数にデフォルト式を渡したとき、その引数が省略されたかどうか知る一番よい方法はなんだろう。

ふつうに

class TheClass
  def the_method(a = nil)
    if a.nil?
        do_something
 else
@skoji
skoji / test.html
Last active August 29, 2015 14:14
「発狂した電車」 部分
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test</title>
<style type="text/css">
body {
margin: 1em;
writing-mode: vertical-rl;
-webkit-writing-mode: vertical-rl;
@skoji
skoji / ydml.rnc
Created November 10, 2010 08:51
well-formed YDML definition in Relax NG Compact Syntax
start = element ydml { Block* }
Block = Paragraph* & Center* & Left* & Right* & Quote* & Hasen*
Paragraph = Inline +
Inline = Large|Small|Bold|Image|Ruby|text
Center = element center { Inline+ }
Left = element left { Inline+ }
Right = element right { Inline+ }
Quote = element quote { Inline+ }
Hasen = element hasen { empty }
@skoji
skoji / densho_conv.rb
Created June 9, 2011 03:36
text to HTML convert utility. read from stdin. must define some singleton methods in the initialization block.
require 'uri'
class DenshoConv
attr_accessor :file_prefix, :file_suffix, :title, :stylesheets, :count, :toc, :count_format, :replace_url, :outer_div_class
def init_default_filters
before_filter do
|text|
if @replace_url
URI.extract(text, ['http', 'https']).each { |url|