I am new to Sphinx. I am writing some documentation for embedded UDFs that requires a code block to contain 2 languages (e.g. SQL and python). At present I can only see how to have a single highlight language in a block.
Is it possible to "switch" languages within a block? Below is an example of reStructuredText that results in 3 code block that I want to merge into one.
Simply removing the second and third "::" doesn't work.
.. highlight:: sql
::
SELECT * FROM
EXTERNAL SCRIPT(
.. highlight:: R
::
#Some R markup
MEANS = matrix(runif(nclust*ndim)*sqrt(nclust)*sep, nrow = nclust)
VARS = matrix(runif(nclust)*ndim, nrow = nclust)
ps = 1:nclust
ps = ps/sum(ps)
.. highlight:: sql
::
)
FROM myshema.mySQLtable
I am 99% sure that this cannot be done by default, and your solution of using separate 'highlight' blocks is the standard procedure to show multiple languages.
I believe that this is for the best anyway as mixing code in one block is usually a bad idea as it can confuse readers.
Also, when converting reStructuredText into HTML for example, a style sheet is used to make everything look pretty, and a default style sheet is included. If you do some research, I'm sure you could edit that style sheet or make your own, perhaps making the 'border' invisible and the 'margin-bottom' zero pixels for 'highlight' blocks.
You can try this extension to have different languages in tabs:
https://bitbucket.org/birkenfeld/sphinx-contrib/src/c30b46a0a1b5c21ec9977e6abc598d0654316ac2/examplecode/?at=default
Related
I’m trying to build a mogrt file for PR which will work just like the out of the box buzzwords effect in AE.
So far, I have set up some 20 text layers which are hidden and will work as text fields and I have main text layer with ‘buzzwords’ expression that feeds from text fields 1-20.
My knowledge of expressions is rather basic but I got it to work somehow by altering the first line of expression to
buzz_words = (thisComp.layer(“1”).text.sourceText +’|’+ thisComp.layer(“b”).text.sourceText+’|’)
I realise if I set this up for 20 text layers, this would be rather lengthy code, do you have any recommendations for making this a little bit less so?
Thanks in advance.
(raw code of Buzz words effect below)
buzz_words = "One|Two|Three|Four|Five|Six|Seven|Eight|Nine|Ten";
split_buzz_words_array = buzz_words.split('|');
buzz_frame_rate = effect("Buzz Frame Rate")(1);
buzz_frame = Math.floor(time * buzz_frame_rate);
buzz_index = buzz_frame % split_buzz_words_array.length;
split_buzz_words_array[buzz_index];
I have to work with a PDF form created by a person unknown to me. Why did the program with which the form was created (Word + PDF export?) split the term "Stunde" into "S", "t" and "unde" in line 6909 of the decoded PDF? There is no visual break between the three parts.
/TT1 1 Tf
11.04 0 0 11.04 59.16 476.1203 Tm
(Datum)Tj
/C2_1 1 Tf
<0003>Tj
/TT1 1 Tf
(der)Tj
0.424 -1.315 Td
(Tätigkeit)Tj
-0.0022 Tc 0 11.04 -11.04 0 261.24 437.7203 Tm
[(Ve)-4.6<7267fc74>-4.2(ungssat)-4.2(z)]TJ
/C2_1 1 Tf
0 Tc <0003>Tj
/TT1 1 Tf
-0.0021 Tc 0.935 -1.315 Td
[<2880>-6.1(/)-7.2(S)0.8(t)-4.1(unde)-4.5(\))]TJ % <<< the important line
0 Tc 11.04 0 0 11.04 340.92 468.8003 Tm
(Anlass/Art)Tj
/C2_1 1 Tf
resulting in
[]
To get the source code above, I decoded the PDF file as described here. I have no know-how concerning the PDF file format.
Background: I had to replace the word "Stunde", it drove me crazy to find the place where "Stunde" was written (in parts) within the source code, since no free PDF editor seems to be able to work with horizontal text without problems.
Academic Bonus questions: Is it possible to set the sum over a column as default value for a form field? (Modifiable; changed every time the column is changed.) Why was I able to replace "Stunde" with "Einsatz" without making the PDF file corrupt due to now irregular offsets?
Why did the program with which the form was created (Word + PDF export?) split the term "Stunde" into "S", "t" and "unde" in line 6909 of the decoded PDF?
As #gettalong mentioned in his answer, in your case this most likely has been done to apply kerning.
If you start looking into the outputs of some other PDF producers, you'll see that this export from Word actually is very unobtrusive in regard to splitting words:
there are PDF producers that draw each character individually after explicitly setting the text matrix for it, and
there also are PDF producers that have the width information for the characters of the used fonts set to zero and use the numbers in TJ instructions to forward the current text matrix between characters accordingly.
And this doesn't cover all the variants to be found, not by far...
Thus,
I had to replace the word "Stunde", it drove me crazy to find the place where "Stunde" was written (in parts) within the source code
in your case replacing actually was a fairly trivial task...
Is it possible to set the sum over a column as default value for a form field? (Modifiable; changed every time the column is changed.)
If all the column values in question are stored in form fields, you can use JavaScript to recalculate sums after form changes. To have it serve as "default" only, you can use some other (hidden) field for a flag whether the field has already been touched. Beware, though: JavaScript is not supported by all PDF viewers. Furthermore, the JavaScript object model for PDF is not specified in an independent (like ISO) specification but in an Adobe one which can make interpretation of the specification biased.
Why was I able to replace "Stunde" with "Einsatz" without making the PDF file corrupt due to now irregular offsets?
As we don't know how exactly you applied the changes, this obviously is hard to tell.
Most likely, though, you did corrupt the PDF and the PDF viewers you opened it in merely repair the corruption under the hood. There is a strong tendency in PDF viewers to do such under-the-hood repairs without informing the user; the result is that a large part of the PDFs in the wild actually being broken.
You don't see a visual break but the standard distance between "S", "t" and "unde" has been changed nonetheless. This is done by PDF writers that support e.g. kerning so that the word appear nicer. This is the reason why it is split that way.
I'm trying to get Word to fill in cells in a table. The script works when run as a macro from within Word, but fails when saved as a .vbs file and double-clicked, or run with wscript. This is a part of it.
set obj = GetObject(,"Word.Application)
With obj
With .Selection
MsgBox .text
If (.Information(wdWithInTable) = True) Then
.Collapse Direction:=wdCollapseStart
tCols = .Tables(1).Columns.Count
tRow = .Information(wdStartOfRangeRowNumber)
tCol = .Information(wdStartOfRangeColumnNumber)
For I = 2 To 5
.Tables(1).Cell(tRow, I).Range.Text = "fred" & Str(I)
Next
` now make new row
For I = 1 To tCols - tCol + 1
.MoveRight unit:=wdCell
Next
End If
End With
End With
I have three problems. First, it won't compile unless I comment out the .Collapse and .MoveRight lines. Second, although the MsgBox .text displays the selected text, I get "out of range" errors if I try to access any .Information property.
I'm sure I'm missing something very simple: I usually write software for Macs, and I'd do this using AppleScript. This is my first attempt at getting anything done under Windows.
VBScript and VBA are different languages.
They are a bit similar, but not very. Moreover, VBScript is not like AppleScript; it doesn't let you easily interface with running programs.
The interfaces you'll get from VBScript can behave subtly differently in VBA and VBScript. However, I think you've got two problems here:
:= is invalid syntax in VBScript; you'll need to find an alternative way of calling the function. Try just using positional arguments.
You've no guarantee that this will open the expected file; there could be another instance of Word that it's interacting with instead.
Since your code is not running within the Word environment it would require a reference to the Word object library in order to use enumeration constants (those things that start with wd).
VBScript, however, cannot work with references, which means the only possibility is to use the long value equivalents of the enumerations. You'll find these in the Word Language References. Simplest to use is probably the Object Browser in Word's VBA Editor. (In Word: Alt+F11 to open the VBA Editor; F2 to start the Object Browser; type in the term in the "Search" box, click on the term, then look in the bottom bar.)
The code in the question uses, for example:
wdWithInTable
wdCollapseStart
wdStartOfRangeRowNumber
wdStartOfRangeColumnNumber
wdCell
The reason you get various kinds of errors depends on where these are used.
Also, VBScript can't used named parameters such as Unit:=. Any parameters must be passed in comma-delimited format, if there's more than one, in the order specified by the method or property. If there are optional parameters you don't want to use these should be left "blank":
MethodName parameter, parameter, , , parameter
Using Actuate eReport Designer Professional 9 SErvice Pack 3 Fix 2
I am attempting to set a text control's ValueExp property to display a string consisting of a division result concatenated with some static text. I want the division result to display as an integer if there is no remainder. Otherwise, I want only 1 decimal place.
There will be conditional logic involved, but I will be able to handle that. What I am really looking for is, using the Expression Builder only, can I format numbers. For example, how would I get the expression, 5/3 & " text" to display 1.7 text? This guess,
round(5/3, 1) & " text"
threw errors for "illegal variable use (round)" and "operator not found for these types"
From Dominique's answer, this effort:
BirtMath.round(5/3, 1)
resulted in an illegal variable use on BirtMath.
Try this:
BirtMath.round(5/3, 1) + " text"
(tested on BIRT Eclipse designer, this should be the same with actuate professional designer)
What finally got the job done was:
Format(5/3, "##.#") & " text"
Dominique's answer refers to BIRT, which is a completely different technology/product.
If you want to display a numeric value with special formatting, a Text Control is not the best choice here. Instead, you should use a numeric control of the appropriate type (for example, a Double Control) and either override the GetText() method of that control to handle the display formatting or use Conditional Formatting. The reason this is a better solution is that data search and export will not work properly with a Text Control.
Note that you can use a format pattern like this: "#,##0 \T\e\x\t" instead of concatenating the string; this technique is needed when you are using Conditional Formatting.
Personally, I would prefer you to use Conditional Formatting, because I put a lot of effort into designing that feature of e.Reports, and I'd like to see more people using it. :) But overriding GetText() is probably easier in your specific situation, due to the need to do more complex string manipulation to eliminate the trailing decimals.
I want to add that with BIRT, you can also format the text in a more 'graphic' way, without the need for SQL ... in case it is useful to someone ...
Select the Object - Properties - Format Number - You choose the Format
there is variety for each case and in addition to adding the custom format.
Of course, it is everyone's decision to how format the text, and it is always good to know how it is done in different ways!
I have a JavaScript line similar to:
var a = (b / 2) + (c / 2);
In Dreamweaver, it highlights this segment as a comment and treats it like this:
var a = (b /* 2 ) + (c */ 2);
It's incorrect syntax highlighting and very annoying. Where do I find syntax highlighting definitions and how do I modify them to correct this?
You can delete/modify the regex definition yourself by finding CodeColoring.xml in your Dreamweaver's configuration path. For CS6 in Windows 7, the default is:
C:\Program Files (x86)\Adobe\Adobe Dreamweaver CS6\configuration\
You will then need to find the JavaScript scheme:
<scheme MMString:name="JavaScript/scheme/name" id="JavaScript" ...>
And within it, you'll find the regexp definition:
<regexp name="RegExp" id="CodeColor_JavascriptRegexp" delimiter="/" escape="\\">
<searchPattern><![CDATA[/\e+\\/]]></searchPattern>
</regexp>
This can probably be refined, but I don't use regular expressions in most scenarios so I just deleted this segment. Restart DW, and voila.
If you want to refine the definition, StackOverflow seems to have its regex highlighting down:
var regex = /a+b/;
var number = (window.innerWidth / window.innerHeight) / 2;
This article explains how to do it:
Modifying Dreamweaver’s syntax highlighting
http://realworldz.wordpress.com/2007/10/04/modifying-dreamweavers-syntax-highlighting/
It gives an example of how to add syntax highlighting to the keyword new for VBScript:
Close Dreamweaver if it’s already open.
Go to C:\Documents and Settings\<YOUR USERNAME>\Application Data\Macromedia\Dreamweaver 8\Configuration\CodeColoring
Open the “ASP VBScript.xml” file in Notepad.
Look for the tags and after the one for “Mod”, add in a new one called for the keyword “New” like this; <keyword>New</keyword>
I have looked everywhere and I agree with the answer from this previous question: Dreamweaver CS5 code hinting
There is just not that much control over syntax highlighting. You can use the method described by Robert's answer here to add more reserved words and such. But editing that file does not apply to changing how Dreamweaver handles highlighting of constants and operators.
Here is a reasonable way to change the way you write you code so that you syntax will still be highlighted in examples like this.
<script>
var a =
(b/2) //Because the forward slashes are not on the same line,
+(c/2); //Dreamweaver will not stop highlighting the numbers
//and operators
document.write(a);
</script>
Note: in this specific example your code can also be simplified to var a = (b+c)/2;
Since the characters /([{;,=!|&~^<>+-*%?:} can't be followed by a division sign, this is what I came up with:
<searchPattern><![CDATA[/\s+/\e+\\/]]></searchPattern>
(this one must have at least one whitespace character to avoid conflicts with end-of-line comments)
<searchPattern><![CDATA[(\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[[\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[{\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[;\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[,\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[=\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[!\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[|\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[&\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[~\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[^\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[<\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[>\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[+\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[-\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[*\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[%\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[?\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[:\s*/\e+\\/]]></searchPattern>
<searchPattern><![CDATA[}\s*/\e+\\/]]></searchPattern>
For scenarios like if (x) /foo/.exec('bar'), just put the RegExp in parenthesis to format it properly. The only other ill effect is that the preceding character will just be formatted as regular text (not bold or colored).