Raw Code Download: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
(→‎With 'source': corrected C++ cited code)
Line 34: Line 34:

Here is a working example using code taken from [http://www.graphicslab.org/Blog/Adding-a-new-Command-to-the-Scribus-Scripter graphicslab.org]
Here is a working example using code taken from [http://www.graphicslab.org/Blog/Adding-a-new-Command-to-the-Scribus-Scripter graphicslab.org] (bad link Err 404)

Revision as of 07:56, 25 September 2014

This wiki is capable of letting users download raw code embedded into the pages. Please see Mediawiki_RawFile for more details, especially the examples at the Examples page.

With 'syntaxhighlight'

In short, so as to cite python script code with proper syntax hilight, use the following tag <syntaxhighlight lang='python'> and close your cite with </syntaxhighlight> THIS WORKS.

Exeample :

def getCSVdata():
    """opens a csv file, reads it in and returns a 2 dimensional list with the data"""
    csvfile = scribus.fileDialog("csv2table :: open file", "*.csv")
    if csvfile != "":
            reader = csv.reader(file(csvfile))
            for row in reader:
                for col in row:
            return datalist
        except Exception,  e:
            scribus.messageBox("csv2table", "Could not open file %s"%e)

With 'source'

  • Use either <source lang=xxxxx></source> tags where xxxxx is the language such as 'bash', 'python', 'cpp' and so on around your code snippets

or for more power use the specially designed {{#fileanchor: myotherscript.sh}} and {{#filelink: myotherscript.sh}} templates as shown in the long example.

Here is a working example using code taken from graphicslab.org (bad link Err 404)

Save the following code as [{{#file: cmdtext.cpp}} cmdtext.cpp]

/*! docstring */
QT_TR_NOOP("repeatText(n, [\"name\"])\n\
Repeat the text of the text frame \"name\" n times.\n\
If \"name\" is not given the currently selected item is used.\n"
/*! Repeat text */
PyObject * scribus_repeattext(PyObject * /*self*/, PyObject * args);