FAQ indexer offerred for ruby faq 
Author Message
 FAQ indexer offerred for ruby faq

As a newbie project, I wrote a faq indexer, to add a section of links at the front of the ruby faq. I think it is nice to have
an overview of all the faqs in the faq. Feed it your rubyfaqall.html file and it will add a links section to it.

# Takes a faq that is organized into numbered headings and creates a set of links at
# the top of the file. It expects headings to be numbered something like: 1., 1.1, 1.2, etc.
# Expects filename on the command line.
# It assumes headings are embedded in <H2> tags.
# It will strip off existing <A NAME=...> tags.
# Edits existing file in place.

file = open(ARGV[0], "r")
fileStr = file.read
file.close

hash = {}
# FIND HEADINGS, HASH THEM BY MAJOR NUMBER, AND ADD BACK <A NAME...>
fileStr.gsub!(/<h2>(.*)<\/h2>/i) do |h|
  heading = $1
  heading.sub!(/<A NAME=[^>]*>/i, "")
  heading.sub!(/<\/A>/i, "")
  if (heading =~ /(\d+)\.(\d*)/)
    majorNum = $1.to_i
    minorNum = ($2 == "") ?  0 : $2.to_i
     hash.has_key?(majorNum) ? hash[majorNum].push( [minorNum, heading] )                                                   :
hash[majorNum] = [ [minorNum, heading] ]
    "<H2><A NAME=\"#{$1}.#{$2}\">" + heading + "</A></H2>"
  end
end

# CREATE LINK SECTION
lines = []
hash.sort.each do |a|
  majNumber, array = a[0], a[1]
  for subArr in array
    minNumber, heading = subArr[0], subArr[1]
    minNumber = (minNumber == 0) ? "" : minNumber
    lines.push("<A HREF=\"##{majNumber}.#{minNumber}\">" + heading + "</A><BR>")
  end
  lines.push("<p><p>")
end

fileStr.sub!(/<h2>/i, lines.to_s + "<H2>")

file.open(ARGV[0], "w")
File.truncate(ARGV[0], 0)
file.print(fileStr)
file.close



Thu, 18 Mar 2004 00:07:58 GMT  
 FAQ indexer offerred for ruby faq

Quote:

> As a newbie project, I wrote a faq indexer, to add a section of
> links at the front of the ruby faq. I think it is nice to have an
> overview of all the faqs in the faq. Feed it your rubyfaqall.html
> file and it will add a links section to it.

That's great. In fact, I currently generate the FAW from SGML (a
mistake, I admit) so I can probably get the index to be generated as
part of the process if people want.

To be honest, I'm kind of thinking of something of a reorganization of
the FAQ: it's too hard to add stuff. I'm not too keen on Faq-o-matic:
does anyone know of any other good FAQ systems out there. I'd like to
be able to represent the FAQ as HTML/XML, PDF, and postscript as a
minimum. I'd like to be able to have lists of pending questions, and a
system which allows folks to submit answers. It needs to be searchable
and indexed, with a decent hierarchy as well.

Any ideas?

Dave



Fri, 19 Mar 2004 10:54:43 GMT  
 FAQ indexer offerred for ruby faq

Quote:

> To be honest, I'm kind of thinking of something of a reorganization of
> the FAQ: it's too hard to add stuff. I'm not too keen on Faq-o-matic:
> does anyone know of any other good FAQ systems out there. I'd like to
> be able to represent the FAQ as HTML/XML, PDF, and Postscript as a
> minimum. I'd like to be able to have lists of pending questions, and a
> system which allows folks to submit answers. It needs to be searchable
> and indexed, with a decent hierarchy as well.

> Any ideas?

I have been working on this. I have searched the web for XML DTDs or
Schemas appropriate for FAQs, but couldn't find anything I liked. I have
written my own DTD, based on XHTML 1.1 modules (so you can use most of
the (X)HTML tags you are used to for the text), with a few added
structural tags (faq, question, answer...). The english and french
versions of the FAQ have been modified to reflect this DTD. I am
currently working on the necessary XSLT stylesheets. The one for HTML
should be straightforward. I plan to write one to transform the source
into TeXML (an XML dialect representing (La)TeX source), and I have a
Ruby script to transform this into{*filter*}(so PDF and PS will be easy to
get).

I had not released anything yet because I wasn't sure how far I would
get (I don't have lots of time to work on it these days). Also, without
stylesheets, it's pretty useless now. I will release it tomorow (I don't
have the files with me) and announce the URL here.

--
Pierre-Charles David (pcdavid <at> emn <dot> fr)
DEA Informatique, cole des Mines de Nantes, France



Fri, 19 Mar 2004 15:55:33 GMT  
 FAQ indexer offerred for ruby faq

Quote:
> [...]
> Also, without
> stylesheets, it's pretty useless now.
> [...]

I can help you to make the xslt stylesheets, if you want. Just tell me.


Fri, 19 Mar 2004 18:38:26 GMT  
 FAQ indexer offerred for ruby faq

Quote:


>> To be honest, I'm kind of thinking of something of a reorganization of
>> the FAQ: it's too hard to add stuff. I'm not too keen on Faq-o-matic:
>> does anyone know of any other good FAQ systems out there. I'd like to
>> be able to represent the FAQ as HTML/XML, PDF, and Postscript as a
>> minimum. I'd like to be able to have lists of pending questions, and a
>> system which allows folks to submit answers. It needs to be searchable
>> and indexed, with a decent hierarchy as well.

>> Any ideas?

> I have been working on this. I have searched the web for XML DTDs or
> Schemas appropriate for FAQs, but couldn't find anything I liked. I have
> written my own DTD, based on XHTML 1.1 modules (so you can use most of
> the (X)HTML tags you are used to for the text), with a few added
> structural tags (faq, question, answer...). The english and french
> versions of the FAQ have been modified to reflect this DTD. I am
> currently working on the necessary XSLT stylesheets. The one for HTML
> should be straightforward. I plan to write one to transform the source
> into TeXML (an XML dialect representing (La)TeX source), and I have a
> Ruby script to transform this into{*filter*}(so PDF and PS will be easy to
> get).

> I had not released anything yet because I wasn't sure how far I would
> get (I don't have lots of time to work on it these days). Also, without
> stylesheets, it's pretty useless now. I will release it tomorow (I don't
> have the files with me) and announce the URL here.

The files are available (with some notes) at:
        http://www.*-*-*.com/ #rubyfaq-xml

I'm waiting for your comments.

--
Pierre-Charles David (pcdavid <at> emn <dot> fr)
Computer Science PhD Student, cole des Mines de Nantes, France
Homepage: http://www.*-*-*.com/



Sat, 20 Mar 2004 16:38:49 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Ruby books (Ruby NG FAQ, Ruby FAQ, home page)

2. FAQ indexer -- user this version!

3. RUBY NEWSGROUP FAQ -- Welcome to comp.lang.ruby!

4. RUBY NEWSGROUP FAQ -- Welcome to comp.lang.ruby!

5. Ruby Newsgroup FAQ (comp.lang.ruby)

6. RUBY NEWSGROUP FAQ -- Welcome to comp.lang.ruby!

7. Meta FAQ: where are the FAQ?

8. comp.lang.forth FAQ-lite: A brief synopsis of the FAQ

9. 'FAQ (pointer to FAQ)

10. FAQ: Verilog FAQ : November 15, 2002

11. FAQ: Verilog FAQ : July 1, 2001

12. OT: A FAQ, but not *my* FAQ (humor)

 

 
Powered by phpBB® Forum Software