Using the OpenXmlSDK 2.0 I am reading and writing to powerpoint documents. We have a situation where a simple string within a powerpoint document has its whitespace stripped.
The example sentence within a single paragraph occurs when several inline markup changes are made to the one paragraph. It can be a little tricky to recreate the markup below, but writing the sentence in full using the powerpoint markup and then applying the formatting seems to produce the results below.
The quick brown fox.
This results in markup roughly similar to:
<a:p>
<a:r>
<a:t>The</a:t>
</a:r>
<a:r>
<a:t> </a:t>
</a:r>
<a:r>
<a:t b="1">quick</a:t>
</a:r>
<a:r>
<a:t> </a:t>
</a:r>
<a:r>
<a:t i="1">brown</a:t>
</a:r>
<a:r>
<a:t> fox</a:t>
</a:r>
</a:p>
This all looks like it's working fine, and opens correctly within the PowerPoint client. But when opening, making changes elsewhere in the presentation using the OpenXmlSDK, saving and closing the document the markup has been simplified to:
<a:p>
<a:r>
<a:t>The</a:t>
</a:r>
<a:r>
<a:t /> <!-- Whitespace missing, causes PowerPoint to ignore it. -->
</a:r>
<a:r>
<a:t b="1">quick</a:t>
</a:r>
<a:r>
<a:t /> <!-- Whitespace missing, causes PowerPoint to ignore it. -->
</a:r>
<a:r>
<a:t i="1">brown</a:t>
</a:r>
<a:r>
<a:t> fox</a:t>
</a:r>
</a:p>
Is there a trick to indicate in the markup to retain the space? Or another way we can structure these runs to include the spaces?
You need to do <a:t xml:space="preserve"> </a:t>
The xml:space="preserve" tells it to hang on to the whitespace (written from memory - may have the syntax wrong).
Related
I have been using Mendeley's Microsoft Word plugin to easily reference papers in my Mendeley Desktop library.
However, I've noticed that the IEEE format for the bibliography/citation is incorrect with regards to referencing conference proceedings and theses.
On the IEEE citation guide: http://www.ieee.org/documents/ieeecitationref.pdf
It shows that the city of the conference should be included in the citation of a conference paper. However, Mendeley's IEEE CSL file does not include this detail.
<macro name="event">
<choose>
<if type="paper-conference speech" match="any">
<choose>
<!-- Published Conference Paper -->
<if variable="container-title">
<group delimiter=", ">
<group delimiter=" ">
<text term="in"/>
<text variable="container-title" font-style="italic"/>
</group>
<text variable="event-place"/>
</group>
Should be changed to:
<macro name="event">
<choose>
<if type="paper-conference speech" match="any">
<choose>
<!-- Published Conference Paper -->
<if variable="container-title">
<group delimiter=", ">
<group delimiter=" ">
<text term="in"/>
<text variable="container-title" font-style="italic"/>
</group>
<text variable="publisher-place"/>
</group>
Since event-place is not a keyword that maps to the "city" field in Mendeley; the correct variable is "publisher-place".
Two options, use this formatted one that I just made, or follow the steps I did to make this change in the CSL Visual Editor.
Just use the corrected file
While in Mendeley Desktop, go to View menu, "Citation Style ->" and click "More Styles..."
Click on the tab "Get More Styles", and enter the following link into the "Download Style:" text box, then click Download
http://csl.mendeley.com/styles/451326401/ieee-CS-edited
Done!
Make your own corrections
While in Mendeley Desktop, go to View menu, "Citation Style ->" and click "More Styles..."
Right Click on IEEE and choose "Copy Style Link"
Open up a web browser, and paste the link and hit enter, it should download a file called "ieee.csl"
Open up a web browser that isn't Chrome, as this doesn't work in Chrome, and go to the page http://csl.mendeley.com/visualEditor/
Login using your Mendeley credentials
Click on the "Visual editor" tab at the top if it's not already selected.
Hover over "Style" and choose "Load Style..."
Browse and select the "ieee.csl" file that was downloaded earlier.
Under "STYLE INFO" and "Info", rename the Title to something new.
Navigate to the following
BIBLIOGRAPHY
->Layout
-->Conditional
--->Else-of paper-conference OR...
---->Group
----->event (macro)
------>Conditional
------->If paper-conference OR speech
-------->Conditional
--------->If container-title
--------->Group
----------->event-place (variable)
Click on event-place (variable) and in the editable section to the right, change the variable from "event-place" to "publisher-place"
Then go back to the Style menu and choose "Save Style As..."
Save this style, and it should automatically add it to your Mendeley Desktop
Done!
Mendeley does not show the thesis citations correctly in IEEE format. It should be like this:
[1] J. K. Author, “Title of thesis,” M.S. thesis, Abbrev. Dept., Abbrev. Univ., City of Univ., Abbrev. State, year.
[2] J. K. Author, “Title of dissertation,” Ph.D. dissertation, Abbrev. Dept., Abbrev. Univ., City of Univ., Abbrev. State,
year.
However, the thesis type and department name are not showing!!
I've been doing development in TWIG lately. It is an html templating language that is very simple and robust.
I've set notepad++ to automatically treat .twig files as html. This is ok, but I don't get any syntax highlighting on my twig functions.
The twig syntax is incredibly simple (by design) and would be easy to add to notepad++. The problem is, everything I find on this subject is either about creating a new language definition (and I do not want to reinvent the html definition), or modifying the color for existing syntax bits in a language.
Is there any way to copy a language definition and then modify it in notepad++? If not, is there any way in notepad++ to add extra syntax bits to an existing language definition?
edit
TWIG is an html template language/engine. they syntax for it is the same as html, with the addition of a few open/close tags (specifically {% %}, {{ }}, and {# #}) for control statements. you can read more about it at the twig website
edit #2
Based on the answer from Brian Deragon, I have been investigating 3 files. Heres what I've figured out/done so far:
\plugins\APIs\html.xml - Seems to define keywords, for autocomplete. I made a copy of the file named twig.xml
langs.model.xml - Again, a list of keywords, with all the languages in 1 XML file. I copied the HTML object and replaced the name and ext parameters with twig.
stylers.model.xml - Has a list of different items, and style information (color, bg color, font, etc) for each. I copied the HTML section and changed the name and desc parameters to twig.
Those changes done, I opened up a twig file in notepad++, hoping to see it listed in the language options. Sadly, it has not appeared, leading me to believe that some of this is hard coded (and thus what I want might not be possible).
The stylers.model.xml is interesting, though. Each entry has a bunch of items, defined like this:
<LexerType name="twig" desc="TWIG" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="COMMENT" styleID="9" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="TAG" styleID="1" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="TAGEND" styleID="11" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
...
</LexerType>
Those seem to be where the styles are defined for the different elements. I can't find anywhere where those elements are defined though. langs.model.xml has a definition for comment start/end, but not for any other delimiters. what I really need is a place to tell notepad++ to treat { } as a delimiter, much like it does for < > now.
edit #3
I am also looking at this list of user defined languages for notepad++ http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=User_Defined_Language_Files
User defined languages use a different engine, but i might be able to find one in there that is similar to html enough that I can adapt it.
You should be able to just copy and edit the XML definition file (html.xml); as long as you don't need stuff beyond the basics, like code-folding, advanced coloring based off of case-handling blocks or multiple conditionals, separate formatting for lead characters, label coloring, xml-based commenting, language mixing (coloring of embedded scripts), support for coloring of duck-types, etc. If you need anything "advanced" you need to write your own lexer, in which case most of the below applies.
Even still, the templates I listed below should give you a head-start on your own language definition file.
As far as I'm aware, Notepad++ uses Scintilla Lexers for determining its code rules.
You'll have to create your own lexer, but...the HTML Scintilla Lexer is already included in the Scintilla source code.
Then you would insert your custom lexer using a plug-in, like Gary's Lua Highlighter Plugin.
Resources for building a custom lexer:
How to write a scintilla lexer
That being said, Geany is very similar to Notepad++ (based off the same engine, Scintilla), so you might want to see whether it's already been done for Geany, or whether there's an open-source project for it in the works. This would at least give you a head start.
If that doesn't help, there are IDEs and editors with Twig support built-in, like:
Eclipse
Netbeans
GEdit (which has a Windows binary, if needed)
JetBrains PhpStorm
GEdit has published their XML definition of the language here, which might help as a reference when creating your own definition file or lexer; there's also another template published by the guys from Twig here that might be of some help.
Here are the best Notepad++-specific tutorials for creating custom lexer's/User Defined Languages I can find:
User Defined Languages
How to create a user-defined language in Notepad++ based on an existing language?
If you want to get brave and build your own Scintilla dll, reference these threads, to see a guy who got it working, and to show up in the language list (use the previous/next thread message to see responses, or the thread index; it's a mailing list, so its UI isn't the best)
http://osdir.com/ml/editors.notepad++/2007-02/msg00021.html
Hope that helps or gets you at least more of a head start!
I made a Highlighter for it here:
https://github.com/Banane9/notepadplusplus-twig
Possible duplicate of this post: https://superuser.com/questions/40876/assigning-custom-extensions-to-a-languages-syntax-highlighting-in-notepad
All you need to do is add your custom extension in Settings->Style Configurator
Click on HTML and add your extension in the User Ext box.
EDIT: If you want to add more rules to your language, you might have to add another XML in notepad++->plugins->APIs
If you think it's like HTML, just copy over html.xml and save as twig.xml
Add more rules to this XML file
I need to highlight every whole block of code that is inside curly braces, so I created a rule:
<context id="action-body" style-ref="action-body" extend-parent="true">
<start>{</start>
<end>}</end>
<include>
<context ref="builtin-vars" />
<context ref="keywords" />
</include>
</context>
It highlights code, keywords and vars inside correctly, but it of course stops if there is another closing curly bracket inside. I know that it is not trivial for regular expressions to check level of recursion, but may be gtkSourceView syntax has something special for cases like these?
It is a serious thing, because a language (PegJS, in fact) I am making highlighting for can contain JavaScript code only inside curly braces, not outside. And I want to highlight them with one color exluding :)
Related:
Regex to get string between curly braces "{I want what's between the curly braces}"
How can I extract a string between matching braces in Perl?
This way (from) highlights ok (gedit goes a little slow when cursor in braces) when such syntax is used on a single line, but not for multi-line:
<context id="action-body" style-ref="action-body">
<match>(\{(?:[^{}]*|(?0))*\})</match>
<!-- <include>
<context ref="builtin-vars"/>
<context ref="keywords"/>
</include> -->
</context>
(and it do not allows me to use included contexts, but the spec says I can :( )
I am trying to output some HTML video tags park of which include
<source src="${Model.WebMFilename}" type='video/webm; codecs="vp8, vorbis"' />
However in the browser this renders as
<source vorbis""="" vp8,="" type="video/webm; codecs=" src="VP8_645001.webm"></source>
Any idea how I stop Sparkview reformatting the output?
Are you sure about your output? I ran this exact scenario through a unit test in the source code and I got the following:
Input:
<source src="${Model.WebMFilename}" type='video/webm; codecs="vp8, vorbis"' />
Result:
<source src="VP8_645001.webm" type="video/webm; codecs="vp8, vorbis"" />
This looks like a "feature" in Spark is getting in the way here, and this is becoming more prevalent with client side frameworks, json popularity and HTML5 attributes usage.
The "feature" I speak of is that Spark can read your input and you can have single or double quotes surrounding your attributes and it will understand the value inside the attribute without an issue, but there is a current side effect of view compilation that automatically (and incorrectly) replaces the surrounding attributes with double quote instead of the quote type you actually used.
I am currently working on a fix for this in the source code. In the mean time, you could try and place your double quotes on the outside of the attribute and try single quotes on the inside although I know this does break some of the client side frameworks since they don't expect that. Can you try this instead (Note: single quote on the inside):
<source src="${Model.WebMFilename}" type="video/webm; codecs='vp8, vorbis'" />
Hope that helps,
Rob
I managed to get the desired output by wrapping the single quote !{"'"} so
<source src="${Model.WebMFilename}" type=!{"'"}video/webm; codecs="vp8, vorbis"!{"'"} />
Rendered
<source src="VP8_645001.webm" type='video/webm; codecs="vp8, vorbis"' />
I would like to know if this is possible to add special character into the CRM (4.0) SiteMap entity (SiteMap XML files). I mean when we modify the menu located on the left I would like to have some HTML encoded character. By example ® or some other special characters.
I tried to do the following:
<Area Id="MyArea" Icon="/_imgs/resourcecenter_24x24.gif">
<Titles>
<Title LCID="1033" Title="Title english ®"/>
<Title LCID="1036" Title="Title french ®"/>
</Titles>
<Descriptions>
<Description LCID="1033" Description="Description EN ®"/>
<Description LCID="1036" Description="Description FR ®"/>
</Descriptions>
<Group Id="MyArea_Group">
<SubArea Id="mySubArea"
Url="https://toMyWebSite/Page.aspx" AvailableOffline="false" >
<Titles>
<Title LCID="1033" Title="My Item"/>
<Title LCID="1036" Title="My Item French"/>
</Titles>
</SubArea>
</Group>
</Area>
This actually show "Title English ®" in my left menu area instead of "Title English ®".
Does anyone have a solution?
(Note: I already tried to put the character directly with "alt-0174" but it didn't worked.)
EDIT: My initial response was incorrect. Use the numbered HTML escape (in this case ®) to get those characters into the sitemap.
Just put ® instead of what you have. The & is being escaped and then it just outputs the characters reg; because that isn't an HTML escape code.