Skip to content

Commit

Permalink
* wiki style: fix bug about blockquote grammar.
Browse files Browse the repository at this point in the history
	* etDiary style: update.
	* release 1.5.3.


git-svn-id: https://tdiary.svn.sourceforge.net/svnroot/tdiary/trunk/core@1175 7f22e88f-374d-0410-998f-c91420d97ba2
  • Loading branch information
tadatadashi committed Feb 23, 2003
1 parent d12b0cc commit de592e0
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 68 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
2003.02.23 TADA Tadashi <sho@spc.gr.jp>
* wiki style: fix bug about blockquote grammar.
* etDiary style: update.
* release 1.5.3.

2003.02.21 TADA Tadashi <sho@spc.gr.jp>
* wiki style: modify blockquote grammar.
* some documents update.
Expand Down
20 changes: 4 additions & 16 deletions misc/style/etdiary/README.rd
Expand Up @@ -2,7 +2,7 @@
= etDiaryスタイル

== etDiaryスタイルとは
((<tDiary|URL:http://www.tdiary.org/>)) の変種である((<etDiary|URL:http:/www.enbug.org/etdiary.html>)) の書式をtDiary本体で利用するためのスタイルです.
((<tDiary|URL:http://www.tdiary.org/>)) の変種である((<etDiary|URL:http://www.enbug.org/etdiary.html>)) の書式をtDiary本体で利用するためのスタイルです.

基本的にはtDiaryスタイルと同じくHTMLをベースとした書式ですが, HTMLタグを意識せずとも
だいたい見た目の通りになる
Expand Down Expand Up @@ -58,21 +58,9 @@ etDiary
* <h3>ではなく<h4>で囲みたいときは「<<<>」と「>>」で囲む.
* サブタイトルの中身がない場合, つまり, 「<<>>」と書かれた場合, サブタイトルなしで新しいセクションを開始する.
*<<<>>>」と書かれた場合もサブタイトルなしで新しいセクションを開始する. ただし, アンカーリンクは生成しない.
* 二つ以上の改行は段落の区切りとなる. ただし <pre> ... </pre> タグ内はその限りではない.
* 段落の初めが「<」の場合, その段落は整形対象外となる. これが嫌なら, スペースを先頭に入れると良い.

== バグおよびTODO
現在の etDiary スタイルは, etDiaryの書式ルールのうち,
終了タグがその段落内に含まれない場合、終了タグが存在する段落まで、空行を残したまま処理される
仕様を満たしておりません. ただし <pre> タグのみはこの仕様のとおりに実装してあります.

また,
* "<""&lt;"
* ">""&gt;"
* "&""&amp;"
の変換は一切行っておりません. すくなくとも <pre> タグ内ではこの処理を行うべきです.

近々これらの修正を施す予定です.
* 二つ以上の改行は段落の区切りとなる.
* 段落の初めが「<」の場合, その段落は整形対象外となる. 終了タグがその段落内に含まれない場合, 終了タグが存在する段落まで, 空行を残したまま処理される. これが嫌なら, スペースを先頭に入れると良い.
* 一般的なHTML同様, "<", ">", "&" はそれぞれ "&lt;", "&gt;", "&amp;" と書く必要がある. ただし, 「<pre>」ではじめた段落に関してはこの限りではない.

== 謝辞
ただただしさんをはじめとする, tDiaryおよびスタイル変更機能を実装いただきました皆様に感謝致します.
Expand Down
80 changes: 47 additions & 33 deletions misc/style/etdiary/etdiary_style.rb
@@ -1,6 +1,6 @@
#
# etdiary_style.rb: tDiary style class for etDiary format.
# $Id: etdiary_style.rb,v 1.1 2003-02-12 15:37:45 kitaj Exp $
# $Id: etdiary_style.rb,v 1.2 2003-02-23 07:18:12 tadatadashi Exp $
#
# if you want to use this style, add @style into tdiary.conf below:
#
Expand Down Expand Up @@ -143,10 +143,16 @@ def block_title?( fragment )
end
end
def p_start
"<p>\n"
"<p>"
end
def p_end
"\n</p>\n"
"</p>"
end
def pre_start
"<pre>"
end
def pre_end
"</pre>"
end
end

Expand Down Expand Up @@ -189,19 +195,26 @@ def block_title?( fragment )
end
end
def p_start
"<P>\n"
"<P>"
end
def p_end
"\n</P>\n"
"</P>"
end
def pre_start
"<PRE>"
end
def pre_end
"</PRE>"
end
end

class EtdiaryDiary
include DiaryBase
include CategorizableDiary

PRE_BEG_REGEXP = /\A<(PRE|pre)[ >]/
PRE_END_REGEXP = /<\/(PRE|pre)>\n*\z/
TAG_BEG_REGEXP = /\A<([A-Za-z]*)([^>]*)>([^\r]*)\z/
TAG_END_REGEXP = /\A([^\r]*)<\/([A-Za-z]*)>\n*\z/
PRE_REGEXP = /\A<[Pp][Rr][Ee][^>]*>([^\r]*)<\/[Pp][Rr][Ee]>\n*\z/
TITLE_REGEXP = /\A<<([^\r]*?)>>[^>]/

def initialize( date, title, body, modified = Time::now )
Expand All @@ -223,28 +236,33 @@ def replace( date, title, body )

def append( body, author = nil )
section = EtdiarySection::new( nil, author )
pre_string = nil
buffer = nil
tag_kind = nil
( body.gsub("\r",'').sub(/\A\n*/,'') + "\n" ).each("") do |fragment|
if pre_string and PRE_END_REGEXP =~ fragment then
section << pre_string + fragment.sub(/\n*\z/,"\n")
pre_string = nil
elsif pre_string then
pre_string << fragment
if buffer and TAG_END_REGEXP =~ fragment and $2.downcase == tag_kind then
section << buffer + fragment.sub(/\n*\z/,"\n\n")
tag_kind = nil
buffer = nil
elsif buffer then
buffer << fragment
else
title = TITLE_REGEXP.match(fragment+"\n").to_a[1]
if title then
@sections << section
section = EtdiarySection::new( title, author )
fragment = fragment[ title.length + 4 .. -1 ]
end
if PRE_END_REGEXP =~ fragment then
section << fragment
elsif PRE_BEG_REGEXP =~ fragment then
pre_string = fragment
if TAG_BEG_REGEXP =~ fragment then
tag_kind = $1.downcase
if TAG_END_REGEXP =~ fragment and $2.downcase == tag_kind then
section << fragment.sub(/\n*\z/,"\n\n")
tag_kind = nil
else
buffer = fragment
end
else
section << fragment
end

end
end
@zerosection = @sections.shift
Expand All @@ -267,15 +285,20 @@ def to_src
src.sub(/\n*\z/,"\n")
end

def to_html_section(section, factory)
def to_html_section(section, factory, title = nil)
return '' unless section.bodies
r = ''
section.bodies.each do |fragment|
if /\A</ =~ fragment then
if PRE_REGEXP =~ fragment then
r << factory.pre_start
r << $1.gsub("&","&amp;").gsub("<","&lt;").gsub(">","&gt;")
r << factory.pre_end << "\n"
elsif /\A</ =~ fragment then
r << fragment.sub( /\n*\z/, "\n" )
else
r << factory.p_start
r << fragment.sub( /\n*\z/, factory.p_end )
r << title if title
r << fragment.sub(/\A\n*/,"\n").sub( /\n*\z/, "\n" + factory.p_end + "\n" )
end
end
r
Expand All @@ -300,11 +323,10 @@ def to_html( opt, mode = :HTML )
title = f.title( date, section ) || ''
if f.block_title?(section) then
r << title << s
elsif /\A</ !~ section.body then
s[4...4] = title
r << s
else
elsif /\A</ =~ section.body then
r << f.p_start << title << f.p_end << s
elsif s then
r << to_html_section( section, f, title )
end
end
r + f.section_end
Expand All @@ -316,11 +338,3 @@ def to_s
end
end
end

#

=begin
Local Variables:
ruby-indent-level: 8
End:
=end
17 changes: 13 additions & 4 deletions misc/style/wiki/wiki_parser.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
#
# wiki_parser.rb: Wiki parser for tDiary style $Revision: 1.3 $
# wiki_parser.rb: Wiki parser for tDiary style $Revision: 1.4 $
#
# Copyright (C) 2003, TADA Tadashi <sho@spc.gr.jp>
# You can distribute this under GPL.
Expand Down Expand Up @@ -37,7 +37,7 @@ def parse( f )
@q = ParserQueue::new
nest = 0
f.each do |l|
l.sub!( /[\r\n]+$/, '' )
l.sub!( /[\r\n]+\Z/, '' )
case l
when /^$/ # null string
@q << nil unless @q.last == nil
Expand Down Expand Up @@ -85,14 +85,23 @@ def parse( f )
inline( $2 )
@q << :DDE << :DE

when /^""\s*(.*)/ # block quote
when /^""$/ # block quote (null line)
if @q.last == :QE then
@q.pop
else
@q << :QS
end
@q << :PS << :PE << :QE

when /^""\s*(.*)/ # block quote
if @q.last == :QE then
@q.pop
@q.pop
else
@q << :QS << :PS
end
inline( $1 )
@q << :QE
@q << :PE << :QE

when /^\s(.*)/ # formatted text
if @q.last == :FE then
Expand Down
18 changes: 5 additions & 13 deletions misc/style/wiki/wiki_style.rb
@@ -1,5 +1,5 @@
#
# wiki_style.rb: WikiWiki style for tDiary 2.x format. $Revision: 1.5 $
# wiki_style.rb: WikiWiki style for tDiary 2.x format. $Revision: 1.6 $
#
# if you want to use this style, add @style into tdiary.conf below:
#
Expand Down Expand Up @@ -88,8 +88,8 @@ def do_html4( parser, date, idx, opt, in_stripped_subtitle = nil )
when :RE

# blockquote
when :QS; r << "<blockquote>\n<p>"
when :QE; r << "</p>\n</blockquote>\n"
when :QS; r << "<blockquote>\n"
when :QE; r << "</blockquote>\n"

# list
when :US; r << "<ul>\n"
Expand Down Expand Up @@ -178,10 +178,6 @@ def do_html4( parser, date, idx, opt, in_stripped_subtitle = nil )
%Q|<%= category_anchor("#{c}") %>|
end.join
end
when :QS
if s.class == String then
r << (s.length == 0 ? "</p>\n<p>" : s)
end
else
r << s if s.class == String
end
Expand Down Expand Up @@ -228,8 +224,8 @@ def chtml( date, idx, opt )
when :RE

# blockquote
when :QS; r << "<BLOCKQUOTE>\n<P>"
when :QE; r << "</P>\n</BLOCKQUOTE>\n"
when :QS; r << "<BLOCKQUOTE>\n"
when :QE; r << "</BLOCKQUOTE>\n"

# list
when :US; r << "<UL>\n"
Expand Down Expand Up @@ -305,10 +301,6 @@ def chtml( date, idx, opt )
end
when :XS
r << s << '">' << s.sub( /^mailto:/, '' )
when :QS
if s.class == String then
r << (s.length == 0 ? "</P>\n<P>" : s)
end
else
r << s if s.class == String
end
Expand Down
4 changes: 2 additions & 2 deletions tdiary.rb
@@ -1,12 +1,12 @@
=begin
== NAME
tDiary: the "tsukkomi-able" web diary system.
tdiary.rb $Revision: 1.89 $
tdiary.rb $Revision: 1.90 $
Copyright (C) 2001-2003, TADA Tadashi <sho@spc.gr.jp>
=end

TDIARY_VERSION = '1.5.2.20030216'
TDIARY_VERSION = '1.5.3'

require 'cgi'
require 'nkf'
Expand Down

0 comments on commit de592e0

Please sign in to comment.