Applescript: Detect double instances - applescript

Here's how a text document in Apple Pages might be structured:
CHARACTER #1: Dialogue
CHARACTER #2: Dialogue
CHARACTER #1: Dialogue
Action description.
CHARACTER #1: Dialogue
My question:
Using Applescript, is there a way to detect that the last two dialogue entries stem from the same character, even though there is an action description in between?
CHARACTER names are defined by a paragraph style and always appear in ALL CAPS.
Many thanks for your time!

Disappointingly, the more recent versions of Pages (like 5.5.2, which I have right now) are very limited in AppleScript support. One should be able to access specific properties of paragraphs, including paragraph style (this seemed to be possible in past versions, 5-6 yrs ago), but this is not possible. You'd be better off exporting as an rtf (for example) and using a more complete script-able app -- but guess what? Pages doesn't even support exporting to RTF.
A quick bit of advice: If you do end up exporting as Word document, use the older "doc" version instead of the "docx" (under 'Advanced' setting in export), or at least test between them. docx can kill screenplay-formatted documents (which you seem to be working with).
I'd also suggest that you be more specific with your question, like what the style consists of, and any code you've actually tried (which is considered basic form here on StackOverflow).

Related

CKEditor enable special characters (its stripping them)

Im using CKEditor as a part of Grocery Crud (this is a php codeignihter crud setup), which uses CKEditor (3.6.5) to edit text fields.
So the problem im having is, some special characters (like Ā) gets somewhat stripped from CKEditor (this happens in the latest version too). Can someone help me make sure these special characters gets treated correctly (specially if there is any flags that i can set maybe)?
To test, just open up a CKEditor anywhere (use the Full demo on the CKEditor website), click the "source" button (to see html mode), then paste the following in the editor: Ā. Then click the source button again (to see the wysiwyg mode) and you will see a Letter A with a line above it. Then click the source again (to see html mode) and you will see that the characters you entered Ā have been replaced by the Letter A with the line above it.
Any thoughts about keeping CKEditor from stripping out the character codes?
The above only happens for some special characters (ones that uses decimal or hex codes) and not others which is a bit strange. And some character codes (that uses hex/decimal) get changed to some other codes (that has non hex/decimal alternatives, which is strange but atleast you end up with the same result).
Alright, let me answer my own question.
You need to add the following to the config:
config.entities_processNumerical = true;
In the case of grocery crud, this is done on the following file: /assets/grocery_crud/texteditor/ckeditor/config.js
More doccumentation can be found here: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.entities_processNumerical
To be fair though, im surprised this is not enabled by default. Not quite sure why.

When editing html in VS2013, I want to be able to type & [ampersand space] without getting &Aacute. How can I set that?

When editing an html file in VS2013, when I type an ampersand followed by a space, the editor automatically gives me &Aacute instead of just &. Is there a way to turn this off with high granularity? I don't want to disable the autotype feature entirely (at least, not yet). But this one is (in my opinion) ridiculous, since I don't ever use &Aacute (it's not a common character in English, to say the least).

Sublime Text autocomplete suggestions looks corrupt, how to fix?

Not sure what is happening to my installation of Sublime Text, when ever autocomplete drop down appears it is populated with a bunch of corrupted looking suggestions, this just started recently. I have Googled around and have not yet seen another person with the same issue. I've already tried uninstalling, throwing out User/me/Library/Application Support/Sublime Text 3 folder, and re-installing, but still the corrupted text shows up in my autocomplete. I am working on a Macbook Air, I also use a Macbook Pro at work with the same setup and have never seen this happen before?
As established in the comments, you have base64-encoded strings (likely an inline image) elsewhere in your file. Sublime's default autocomplete populates its choices menu with elements from your file, and uses fuzzy matching to bring up selections. Since base64 can contain all letters and numbers, chances are that any sequence you're typing may match, and that string will be brought to the top of the autocomplete dropdown.
There are a couple of ways around this. First, if the base64 content is actually scoped as a string (i.e., it's surrounded by single or double quotes), you can add the following line to your settings (Preferences -> Settings-User):
"auto_complete_selector": "source - comment - string, meta.tag - punctuation.definition.tag.begin"
This should hopefully solve your problem for the time being, with the downside that you lose any other string-encoded information that you may wish to be in autocomplete.
You can also try using an autocomplete engine like SublimeCodeIntel (works for multiple languages, including JS) or TernJS. These can have the option of turning off Sublime's internal autocomplete mechanism, and just filling in the choices with their generated content.

Reformatting code in text mate to established code conventions - Visual studio's ctrl K+D equivalent on Text Mate

Can anyone tell me if there's a quick way to format your code in Text Mate, similar to pressing ctrl K+D in Visual studio?
Thanks!
Edit by Damien_The_Unbeliever:
For those not familiar with Ctrl K+D, it doesn't just indent code - it reformats it using the generally established formatting conventions in the editor - it may replace spaces with tabs or vice-versa for the indentation, ensure code is consistently indented, move braces to separate lines, etc.
TextMate reindenting and reformatting varies a little depending on the language you're using.
You can generally use the Text menu, that depending wether you have an active selection or not it will show you different commands under it. For example, if you have selected a section of code, there will be a Indent Selection menu item. If you have no active selection, it will be Indent Line.
To have this working properly, be sure to select the current language, if it isn't assigned yet (like on unsaved documents). If you're working with HTML, it will simply indent the lines depending on what's above it. It will keep line breaks intact.
If you need something to break out tags on new lines and properly format the document, you should use the Tidy command that is found in the Bundles menu, under HTML (or simply by using the shortcut CTRL+SHIFT+H. If you have a selection active at the moment that you use it, it will simply reindent that section. If instead you have no selection, it will properly reformat the whole document, including checking for tag validity and other errors.
The Bundles for other language have similar commands, like XML (still Tidy) and Javascript (that has a Reformat Document command).
As an ending note, I simply suggest to look into the Bundles menu; there are many little gems in it. ;)
Did you look in the menu bar? Under Text you have a couple of Reformat… entries that may fit your needs.
Beside these native features, some bundles — like the JavaScript one — have custom Reformat… commands : click on the little cog button at the bottom and explore your current language's bundle's content.

Windows text editor that shows/hides lines based on RegEx or Grep syntax?

One of my application components produces some extremely hairy log files. They require a lot of poking and prodding before they produce useful information. I'm on the hunt for a text editor for windows that will let me enter text in either RegEx or Grep-style syntax, and automatically show/hide the relevant lines.
Does anyone know of a text editor that has this feature?
Thanks!
IVR Avenger
I know it's answered already, but http://glogg.bonnefon.org/ is the perfect answer for this. Couldn't live w/o it.
I would recommend Notepad++ as far as a good all-around Windows text editor is concerned - it is very extensible and includes just about every power feature you need to wade through data logs. If your log files are in a well-defined format, you can even use the built-in language editor to define a custom visual scheme for your logs - easier on the eyes.
-matt
GVim with for example, :g command. There are also plugins that allow entering search criteria, and they show relevant lines, and fold everything else.
Emacs, of course (occur), but I think pretty much every editor will do this.
Another option is SlickEdit using it's "Selective Display..." option
Although it wont show/hide based on a regex, Textpad will allow you to search and produce a hyperlinked result file with the lines that will allow you to click into the actual log. Consider the benefit: You can keep the filtered results up on your left monitor, and you can click into the full files and show them on your right monitor to see the context.
SPFLite is free and does just what you want. At least the IBM SPF and ISFP (used on IBM mainframes as part of the MVS operating system) that it emulates is just what you want.
From what I have tried, SPFLite will probably do the job. It can X (exclude) all lines from view, or eXclude lines with a given character or phrase (optionally starting in a certain column) from view. Or after eXcluding all lines, you can display, by Finding, characters or strings (optionally starting in a certain column). I think it also has a macro capability. The original does, and I think this Lite does as well. How robust I do not know. The original could create interactive screens and programs using the MVS TSO Command Language.
I found SPFLite at http://www.spflite.com/
I found that this interface is not so easy to use, but one gets used to about anything if necessary.

Resources