MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Sigil (https://www.mobileread.com/forums/forumdisplay.php?f=203)
-   -   Editing code view in Sigil (https://www.mobileread.com/forums/showthread.php?t=180725)

JJ Joseph 06-08-2012 02:22 AM

Editing code view in Sigil
 
The editing of an html file in the code view mode is hampered by Sigil trying to be clever. If I try to change all instances of an html tag ("<blockquote>", for example, Sigil will do a Find/Replace on the opening tag no problem. But when I try to edit the remaining closing tag ("</blockquote"> for example, I can't do it. Sigil refuses to do anything because now the opening & closing tags don't match any more.

The only way I can complete the "Find & Replace" is to copy the entire file and move it to Notepad, and then copy the file back to Sigil. This seems much too clumsy for a smart application like Sigil. Is there anyway to do large edits without confounding Sigil like this?

meme 06-08-2012 03:15 AM

What version are you running? This works ok for me, but of course I'm using the new beta at the moment.

But you can also do this using Regex, for example change all blockquote (with or without classes) to a simple paragraph then this should work:

Code:

Find: (?sU)<blockquote(.*)>(.*)</blockquote>
Replace: <p>\1</p>


Toxaris 06-08-2012 03:52 AM

Switch Tidy off, that might do it for you.

However, it is better to use RegEx and do the replace in pairs. Unexpected things can and will happen if you let Tidy fix the HTML for you again.

meme 06-08-2012 04:07 AM

Yeah, of course, Tidy. I turn that off immediately these days - make sure you do the same in the beta - although switching to Edit->Clean Source->Pretty Print (and restarting) is my preferred setting now.

Serpentine 06-08-2012 03:13 PM

To replace all of a certain tag:
find: <(/)?blockquote>
replace: <\1newtag>

But yeah, disabling tidy is generally a good plan if you wish to hold on to some sanity (at least in the current release)

theducks 06-08-2012 03:24 PM

Meme
I have a program (Agent Newsreader) that allows the user the option to Save and always use the same layout at startup, regardless of the last

used configuration. It would be kool to also save toggle settings like Tidy, Search showing, Validation results showing

1) (factory) default. (also a command line switch to call this to recover from error/HW configuration changes)
2) Last used (saves state when closing)
3) Saved (snapshot) of windows and button states

meme 06-08-2012 03:38 PM

Quote:

Originally Posted by Serpentine (Post 2108494)
To replace all of a certain tag:
find: <(/)?blockquote>
replace: <\1newtag>

This is much simpler but only works if the original doesn't have classes or other attributes. You could drop the closing > and that might work. But as with every replace you have to make sure it applies to what you're doing :)

DiapDealer 06-08-2012 04:05 PM

find :<(/)?blockquote([^>]*?)>
replace: <\1newtag\2>

JJ Joseph 06-09-2012 02:30 AM

Thanks
 
Quote:

Originally Posted by meme (Post 2107689)
What version are you running?

Version 0.5.3 - it doesn't say if it's a Beta, or what stage of development. I'm not sure if I can exclude Tidy from Sigil. All I know is that I hate working on anything with Tidy hanging over my shoulder. It's OK if I can call it when I need it, but I don't like it popping up unannounced. The same goes for similar "smart" editors like TinyMCE Edit. They're all a total pain in the you-know-what.


All times are GMT -4. The time now is 10:08 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.