Difference between revisions of "User:Kbjarkefur"

Jump to: navigation, search
Line 41: Line 41:




What I have done in my examples I uploaded today was to use <nowiki><pre></nowiki> for multi-line code examples and <nowiki><code></nowiki> for inline code examples, but as they look quite different in color I do not think it is a great solution. Not our top priority perhaps, but since there will be plenty of code examples we should decide on a policy for this.
'''Summary and suggested solution:''' What I have done in my examples I uploaded today was to use <nowiki><pre></nowiki> for multi-line code examples and <nowiki><code></nowiki> for inline code examples, but as they look quite different in color I do not think it is a great solution. Not our top priority perhaps, but since there will be plenty of code examples we should decide on a policy for this.


Both the <nowiki><pre></nowiki> tag and the <nowiki><code></nowiki> tag are html elements that can be formatted with CSS. I think Ritesh's team should be able to format one of them to look more similar to the other. I do not like the red in the <nowiki><code></nowiki> tag that much as it looks like an error so I'd prefer both of them to be like the <nowiki><pre></nowiki> but keep both of them working as they are in terms of position and line break.
Both the <nowiki><pre></nowiki> tag and the <nowiki><code></nowiki> tag are html elements that can be formatted with CSS. I think Ritesh's team should be able to format one of them to look more similar to the other. I do not like the red in the <nowiki><code></nowiki> tag that much as it looks like an error so I'd prefer both of them to be like the <nowiki><pre></nowiki> but keep both of them working as they are in terms of position and line break.

Revision as of 21:30, 26 October 2017

About me

Pages on this wiki I frequently need:

Code snippet example

This part is using the regular <code> tag which is great when writing code in the middle of a sentence:

Ex.1 Use the egen function rowtotal() when aggregating variables.

However, the <code> tag is not great when writing multiple lines of code because there is a space in the formatting between the lines. It doesn't feel like a single code snippet.

Ex.2

gen varA = .
replace varA = 1 if gender == 1
replace varA = 0 if gender == 0

One solution to this that I found was to use the <pre> tag. Multiple lines displays really nice (and I like the color better):

Ex.3

gen varA = .
replace varA = 1 if gender == 1
replace varA = 0 if gender == 0

However, the <pre> tag is no good for when writing code in the middle of a sentence. Ex.4 is the same code as Ex.1 but with a <pre> tag instead of a <code> tag:

Ex.4 Use the egen function

rowtotal()

when aggregating variables.


Summary and suggested solution: What I have done in my examples I uploaded today was to use <pre> for multi-line code examples and <code> for inline code examples, but as they look quite different in color I do not think it is a great solution. Not our top priority perhaps, but since there will be plenty of code examples we should decide on a policy for this.

Both the <pre> tag and the <code> tag are html elements that can be formatted with CSS. I think Ritesh's team should be able to format one of them to look more similar to the other. I do not like the red in the <code> tag that much as it looks like an error so I'd prefer both of them to be like the <pre> but keep both of them working as they are in terms of position and line break.