Re: Grep all content between twp p tags

This WebDNA talk-list message is from

2006


It keeps the original formatting.
numero = 68212
interpreted = N
texte = Dan, (Sorry, I sent the message below yesterday from a webmail account - but I just realised the list rejects HTML emails !!) My objective is to show the first 100 words from a blog post without breaking any html formatting. So I can't just do a listwords as it might cut off the text in the middle of a paragraph or list etc. The solution I came up with is a bit convoluted but it works. - Tom [text]maxwords=3D100[/text] [text]maxblock=3D1[/text] [text]totalwords=3D[/text] [text]extratext=3D[/text] [!] ------------------------------------ ### Pull out empty paragraphs ### [/!][text]_newvalue=3D[grep search=3D(

)|(

%26%23160%3B

)&replace=3D][xBTEXT][/grep][/text= ][! ] ------------------------------------ ### Mark endpoints of Paragraphs & Lists ### [/!][text]_newvalue=3D[grep search=3D(

||)&replace=3D\1 |][_newvalue][/grep][/text][!] ------------------------------------ ### Count words in each paragraph / list ### [/!][listwords words=3D[url][removehtml][_newvalue][/removehtml][/url]&delimiters=3D|][t= ext ]wordcount=3D[/text] [listwords words=3D[url][word][/url]&delimiters=3D .] [text]wordcount=3D[index][/text] [/listwords] [text]totalwords=3D[math][totalwords]+[wordcount][/math][/text] [showif [totalwords]<[maxwords]] [text]maxblock=3D[index][/text] [/showif] [hideif [maxblock]<2] [showif [totalwords]>[maxwords]] [text]extratext=3DT[/text] [/showif] [/hideif] [/listwords][!] ------------------------------------ ### Show the max number of text blocks allowed by maxwords (1st block always shown) ### [/!][listwords words=3D[url][_newvalue][/url]&delimiters=3D|][hideif [index]>[maxblock]][word][/hideif][/listwords] ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Grep all content between twp p tags ( "Tom Duke" 2006)
  2. Re: Grep all content between twp p tags ( "Dan Strong" 2006)
  3. Re: Grep all content between twp p tags ( "Dan Strong" 2006)
  4. Re: Grep all content between twp p tags ( "Tom Duke" 2006)
  5. Re: Grep all content between twp p tags ( "Dan Strong" 2006)
  6. Grep all content between twp p tags ( "Tom Duke" 2006)
Dan, (Sorry, I sent the message below yesterday from a webmail account - but I just realised the list rejects HTML emails !!) My objective is to show the first 100 words from a blog post without breaking any html formatting. So I can't just do a listwords as it might cut off the text in the middle of a paragraph or list etc. The solution I came up with is a bit convoluted but it works. - Tom [text]maxwords=3D100[/text] [text]maxblock=3D1[/text] [text]totalwords=3D[/text] [text]extratext=3D[/text] [!] ------------------------------------ ### Pull out empty paragraphs ### [/!][text]_newvalue=3D[grep search=3D(

)|(

%26%23160%3B

)&replace=3D][xBTEXT][/grep][/text= ][! ] ------------------------------------ ### Mark endpoints of Paragraphs & Lists ### [/!][text]_newvalue=3D[grep search=3D(

||)&replace=3D\1 |][_newvalue][/grep][/text][!] ------------------------------------ ### Count words in each paragraph / list ### [/!][listwords words=3D[url][removehtml][_newvalue][/removehtml][/url]&delimiters=3D|][t= ext ]wordcount=3D[/text] [listwords words=3D[url][word][/url]&delimiters=3D .] [text]wordcount=3D[index][/text] [/listwords] [text]totalwords=3D[math][totalwords]+[wordcount][/math][/text] [showif [totalwords]<[maxwords]] [text]maxblock=3D[index][/text] [/showif] [hideif [maxblock]<2] [showif [totalwords]>[maxwords]] [text]extratext=3DT[/text] [/showif] [/hideif] [/listwords][!] ------------------------------------ ### Show the max number of text blocks allowed by maxwords (1st block always shown) ### [/!][listwords words=3D[url][_newvalue][/url]&delimiters=3D|][hideif [index]>[maxblock]][word][/hideif][/listwords] ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ "Tom Duke"

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Prevent multiple appends with Reload Button (1997) Will webdna execute before a [redirect]? (1999) Searchable WebCat (etc.) Docs ? (1997) WC2/Mac -- Forms not submitting correctly with Mac browsers (1997) WebDNA Quick Reference (Reserved Words) (2000) Listserver problem (1997) RE: [WebDNA] Windows FastCGI thisurl issues (2018) Searching for all records (1998) Search multiple fields (1997) WebCat2b13MacPlugIn - [showif][search][/showif] (1997) Re:quit command on NT (1997) Where's Cart Created ? (1997) PIXO support (1997) More than one db with the same namn (was: WC2f3) (1997) RE: [WebDNA] Redirecting incoming URL request to https page (2018) Friday night shopping site joke (1997) encrypted database (2004) WCS Newbie question (1997) Credit card types (1997) E-Mailer (WebCatb15acgiMac) (1997)