Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

background macro utility

I have my story formatted as white text on a black background. For a part of the story, I want to switch to black text on a white background. I want to do this using a format variable, as in:
(set: $transcriptFormat to (font: "Times New Roman")+(color: black)+(background: white))
However, this only changes the background of the line of text I attach it to. Is there a way in Harlowe to use macros to change the background of the body text? Or will I have to switch to CSS? I ask because I don't want to repeat the same lines of HTML and CSS at the beginning of each passage I want to apply this format to.

Thanks!

Comments

  • After looking at the Harlowe documentation I don't believe that there is a macro that will do what you want.

    You can set your default background and foreground colours using the following CSS:
    (note: the background-color needs to be set on the body tag if you want it to effect the whole page.)

    body {
    background-color: black;
    }
    tw-story {
    color: white;
    }
    If you were using the SugarCube story format you could use passage tag based CSS selectors to change the look of groups of passages by simply adding the same passage tag to each member of the group, this feature was available in most Twine 1 story formats. Unfortunately Harlowe does not currently support passage tags.

    One possible way you can achieve a similar effect is by using a little javascript to assign/remove a class and a missing image hack to call the javascript. The downside of this method is the change in look persists until you manually turn it off.

    Turn the new look on by add the following to the first passage you want to look different, it adds a class to the html element of your story:

    <div style="display: none;"><img src="!@#$" onerror="$('html').addClass('forest')" /></div>
    You can then write CSS that will change the look of the page when the class exist on the html element:

    html.forest body {
    background-color: green;
    }
    html.forest tw-story {
    color: black;
    }
    Turn the new look off by adding the following to a passage when want the look to return to the defaults, it removes the class from the html element of your story:

    <div style="display: none;"><img src="!@#$" onerror="$('html').removeClass('forest')" /></div>
    I hope that helps, someone else may be able to come up with a better workaround.
  • That worked just fine, thanks for your help.
  • Is using a macro for to do this still necessary?
    Or is there a simpler way now that Twine/Harlowe has seen some minor upgrades?
  • auriea wrote:

    Is using a macro for to do this still necessary?
    Or is there a simpler way now that Twine/Harlowe has seen some minor upgrades?

    Which Harlowe minor upgrades are you asking about?
    a. The ones that are part of Harlowe 1.0.1, that comes as part of Twine 2.0.3 or
    b. The ones that are part of Harlowe 1.1.0, which has not been released yet and is still being changed?
  • I don't know what upgrades. I just want to know if it is *possible* Anywhere. At All. to change the colors of different pages of my Twine without using a macro.
    Would love to just use CSS.
    I think I read it was possible in Twine 1 by using tags... How can this be done in Harlowe?
  • Harlowe does not currently support using passage tags to effect global style changes, you can on the other hand use the technique listed previously in this thread to to do so.

    Leon has now released a beta version of Harlowe 1.1.0 which includes the ability to tag passages as either a header or a footer which may allow you to make global style changes based on the passage being shown.
Sign In or Register to comment.